I want to update the lastsync column the problem is the data wont save properly. I used Convert.ToDateTime and DateTime.Parse and still the data wont save properly. I am getting "01/01/0001 12:00:00". What am I doing wrong?
public DateTime LastUpdated { get; set; }
var current_datetime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
string ofretailer_group_sql = "UPDATE tblRetailerGroup SET LastUpdated = '" + DateTime.Parse(current_datetime) + "' WHERE RetailerCode = '" + retailerCode + "'";
await conn.ExecuteAsync(ofretailer_group_sql);
If you are getting 01/01/0001 12:00:00 from your TimeDate field, that means it was never set/updated.
Personally I use query (?) parameters to allow the SQL statement strings to become a bunch of constants that never change and then you just have to assign the parameters for that query in the order they fall within the SQL statement:
Example:
const string ofretailer_group_sql = "UPDATE tblRetailerGroup SET LastUpdated = ? WHERE RetailerCode = ?";
await conn.ExecuteAsync(ofretailer_group_sql, new object[] { DateTime.UtcNow, retailerCode });
Note: I am using UtcNow to remove DST and phone device timezone change issues...
You should create dependency services for file management to save and get a data in IOS and Android level. Here is code how to save and get datetime in file.
PCL Project:- Create the interface
public interface IFileHelper
{
void SaveLastUpdatedDateTimeForData(DateTime dateTime);
DateTime GetLastUpdatedDateTimeForData();
}
IOS/Android Project:- Create one Class to save the data in file.
[assembly: Dependency(typeof(FileHelper))]
namespace ABCD.iOS
{
public class FileHelper: IFileHelper
{
public void SaveLastUpdatedDateTimeForData(DateTime dateTime)
{
try {
string docFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string filePath = Path.Combine(docFolder, "..", "Library", "updatetime.txt");
File.WriteAllText(filePath, dateTime.Ticks.ToString());
} catch (Exception ex) {
Debug.WriteLine(ex.Message);
}
}
public DateTime GetLastUpdatedDateTimeForData()
{
//bool status = false;
string docFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string filePath = Path.Combine(docFolder, "..", "Library", "updatetime.txt");
if (!File.Exists(filePath)) {
return new DateTime(2000, 1, 1);
}
try {
string content = File.ReadAllText(filePath);
DateTime dt = new DateTime(long.Parse(content));
return dt;
} catch (Exception ex) {
Debug.WriteLine("exception in GetLastUpdatedDateTimeForData : {0}", ex.Message);
return DateTime.MinValue;
}
}
}
}
Call the dependency Service in Client/PCL project:
Save updated DateTime:
DependencyService.Get<IFileHelper>().SaveLastUpdatedDateTimeForData(DateTime.Now);
Get Updated DateTime:
var lastUpdatedDateTime = DependencyService.Get<IFileHelper>().GetLastUpdatedDateTimeForData();
It seems to be a conversion issue from Date-String-Date.
I would go for directly saving first DateTime.now in Db and check if the value is saved correctly. If that works then definitely its a conversion issue. Then you can try below solution.
I do conversion like this:
DateTime date = DateTime.ParseExact(current_datetime, "yyyy-MM-dd hh:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
Related
I need to get a NEXTVAL from a SEQUENCE in an Oracle database. The modelbuilder does have a
builder.HasSequence("TABLE_SEQ");
But I have no clue on how to use that. The only way I can think of is scalar executing a raw SQL to retrieve the next value. Is that the way to go or are there better ways to do this?
I've found several posts that say I should use context.Database.SqlQuery() but in my solution that is missing. Do I need to add a library to get this functionality for EF 6.0?
Examples I found:
Example 1:
public int GetNewCertificateTradeRequestIdentity()
{
using var command = _context.Database.GetDbConnection().CreateCommand();
command.CommandText = "SELECT ts.seq_certificate_trade_request.NEXTVAL FROM DUAL";
_context.Database.OpenConnection();
using var reader = command.ExecuteReader();
reader.Read();
return reader.GetInt32(0);
}
Example 2:
users = await context.Database.SqlQuery<User>("Select * from User", new object[] { }).ToListAsync();
Both the _context.Database.GetDbConnection() context.Database.SqlQuery<x> are missing. Where can I find them?
Ok, in EF6 you have the context.Database.GetDbConnection().CreateCommand(). With that command you can execute a query on the database and receive the result. I've also found a solution for getting the tablename from the EF6 Metadata and added an extension method to handle that. Now I can do the the following:
private Tijdverantwoording Create(decimal? mdwid, decimal? deelprjid, Datum? date)
{
if (mdwid == null || deelprjid == null || date == null) throw new ArgumentNullException();
Weekstaatstatus weekstaatStatus = _WeekstaatStatusService.GetOrCreate(mdwid.Value, date.Jaarweekcode, WeekStaatStatussen.InBewerking, DateTime.Now);
var tijdverantwoording = new Tijdverantwoording
{
Tijdverantwoordingid = GetId<Tijdverantwoording>(), // <= Generate id
Mdwid = mdwid.Value,
Deelprjid = deelprjid.Value,
Datum = date.DagDatum,
Syncstatus = (decimal)SyncStatuses.InBewerking,
Syncdate = DateTime.Now.Date,
Weekstaatstatusid = weekstaatStatus.Weekstaatstatusid
};
_modelContext.Tijdverantwoordingen.Add(tijdverantwoording);
return tijdverantwoording;
}
The base class used for a service.
using Microsoft.EntityFrameworkCore;
using MyProjects.Core.Extensions;
using MyProjects.Core.Model;
namespace MyProjects.Core.Services
{
public class ServiceBase
{
private ModelContext? _modelContext;
public ServiceBase(ModelContext modelContext)
{
_modelContext = modelContext;
}
public decimal GetId<T>()
where T : class
{
var command = _modelContext.Database.GetDbConnection().CreateCommand();
var tableName = _modelContext.TableName(typeof(T));
command.CommandType = System.Data.CommandType.Text;
command.CommandText = $"SELECT {tableName}_SEQ.NEXTVAL FROM DUAL";
_modelContext.Database.OpenConnection();
try
{
var result = (decimal?)command.ExecuteScalar();
return result.Value;
}
finally
{
_modelContext.Database.CloseConnection();
}
}
}
}
And the extension method
using Microsoft.EntityFrameworkCore;
namespace MyProjects.Core.Extensions
{
public static class DatabaseExtensions
{
public static string? TableName(this DbContext context, Type type)
{
var entityType = context.Model.FindEntityType(type);
return entityType?.GetTableName() ?? throw new NullReferenceException($"Can't find name for type {type.Name}");
}
}
}
Now I'm working on my Cloud Storage Project and the main idea of it is to use authorization system provided by Identity Framework and let users upload and download files to an existing table (AspNetFiles - created by me). Moreover, it's important to save all uploaded files to folder in project directory (~/wwwroot/Files/). Now I'm on the way to build upload files system, so:
I made new table AspNetFiles in the direction of other AspNet... tables provided by Identity and Upload-Database NuGet func after creating Migration;
Created new "WorkSpaceController" in "~/Controllers/" for managing files (upload, sort in grid and download) for every logged in user;
Created functions for FileManager view (this is the page for displaying upload, grid and delete files experience) + some other functions for saving files in wwwroot, getting logged in user "Id" and etc.
My dbo.AspNetFiles has the next columns:
FileID (PK, int, not null) with identity (1,1) parameter
FileName (varchar(60), not null)
FileData (varbinary(max), not null) - for store uploaded file data in table
FileExtension (varchar(15), not null)
FileDate (varchar(20), not null)
Id (FK, nvarchar(450), not null) as the primary key of logged in user from dbo.AspNetUsers
After debugging application I get some errors:
InvalidCastException: Object must implement IConvertible. System.Convert.ChangeType(object value, Type conversionType, IFormatProvider provider)
InvalidCastException: Failed to convert parameter value from a FormFile to a Byte[]. Microsoft.Data.SqlClient.SqlParameter.CoerceValue(object value, MetaType destinationType, out bool coercedToDataFeed, out bool typeChanged, bool allowStreaming)
So yeah I know that I use a IFormFile type for "FileData: from "FileDataModel" but it's for saving file locally in project folder as I mentioned previously (~/wwwroot/Files/).
I'm a new user in ASP.NET Core, so I tried many ways from YouTube and articles of how to save files locally and in table of SQL database, but I didn't find any way to do it both and save files with existing Identity Framework with connection to logged in user by foreing key "Id" in table for upload files and download to pc.
Hope u can help me with it. Don't gudge too much :D
This is the code:
FileDataModel (in ~/Models/)
namespace TextCloud.Models
{
public class FileDataModel
{
public string FileName { get; set; }
public IFormFile FileData { get; set; }
public string FileExtension { get; set; }
public string FileDate { get; set; }
public string Id { get; set; }
}
}
WorkSpaceController (in ~/Controllers/)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Configuration;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Identity;
using System.Security.Claims;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Protocols;
using System.Data;
using System.Data.SqlClient;
using TextCloud.Models;
using Microsoft.Data.SqlClient;
using Microsoft.AspNetCore.Hosting;
using TextCloud.Areas.Identity.Data;
namespace TextCloud.Controllers
{
public class WorkSpaceController : Controller
{
private readonly IWebHostEnvironment webHostEnvironment;
private readonly UserManager<TextCloudUser> _userManager;
public WorkSpaceController(IWebHostEnvironment webHostEnvironment, UserManager<TextCloudUser> userManager)
{
this.webHostEnvironment = webHostEnvironment;
_userManager = userManager;
}
public IConfigurationRoot GetConnection()
{
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appSettings.json").Build();
return builder;
}
public IActionResult FileManager()
{
return View();
}
[HttpPost]
public IActionResult FileManager(FileDataModel model)
{
if (ModelState.IsValid)
{
string uniqueFileName = null;
if (model.FileData != null)
{
DateTime FileDate = DateTime.Now;
model.FileDate = FileDate.ToString("dd/MM/yyyy");
model.Id = _userManager.GetUserId(HttpContext.User);
string uploadsFolder = Path.Combine(webHostEnvironment.WebRootPath, "Storage");
uniqueFileName = Guid.NewGuid().ToString() + "_" + model.FileData.FileName;
string filePath = Path.Combine(uploadsFolder, uniqueFileName);
model.FileExtension = Path.GetExtension(model.FileName);
model.FileName = model.FileData.FileName;
if (model.FileDate != null)
{
string connctn = "Server=DESKTOP-LRLFA5K\\SQLEXPRESS;Database=TextCloud;Trusted_Connection=True;MultipleActiveResultSets=true";
SqlConnection con = new SqlConnection(connctn);
con.Open();
string commnd = "insert into AspNetFiles(FileName, FileData, FileExtension, FileDate, Id) values (#FileName, #FileData, #FileExtension, #FileDate, #Id)";
SqlCommand com = new SqlCommand(commnd, con);
com.Parameters.Add("#FileName", SqlDbType.VarChar).Value = model.FileName;
com.Parameters.Add("#FileData", SqlDbType.VarBinary).Value = model.FileData;
com.Parameters.Add("#FileExtension", SqlDbType.VarChar).Value = model.FileExtension;
com.Parameters.Add("#FileDate", SqlDbType.VarChar).Value = model.FileDate;
com.Parameters.Add("#Id", SqlDbType.NVarChar).Value = model.Id;
com.ExecuteScalar();
con.Close();
model.FileData.CopyTo(new FileStream(filePath, FileMode.Create));
}
}
}
return View();
}
}
}
According to your description, I found you directly pass the iformfile to the FileData. You should read the byte array from the iformfile, then store the byte arrary into the database.
More details, you could refer to below codes:
[HttpPost]
public IActionResult FileManager(FileDataModel model)
{
if (ModelState.IsValid)
{
string uniqueFileName = null;
if (model.FileData != null)
{
DateTime FileDate = DateTime.Now;
model.FileDate = FileDate.ToString("dd/MM/yyyy");
model.Id = _userManager.GetUserId(HttpContext.User);
string uploadsFolder = Path.Combine(webHostEnvironment.WebRootPath, "Storage");
uniqueFileName = Guid.NewGuid().ToString() + "_" + model.FileData.FileName;
string filePath = Path.Combine(uploadsFolder, uniqueFileName);
model.FileExtension = Path.GetExtension(model.FileName);
model.FileName = model.FileData.FileName;
if (model.FileDate != null)
{
using (MemoryStream stream = new MemoryStream())
{
model.FileData.OpenReadStream().CopyTo(stream);
string connctn = #"Server=DESKTOP-LRLFA5K\\SQLEXPRESS;Database=TextCloud;Trusted_Connection=True;MultipleActiveResultSets=true";
SqlConnection con = new SqlConnection(connctn);
con.Open();
string commnd = "insert into AspNetFiles(FileName, FileData, FileExtension, FileDate, Id) values (#FileName, #FileData, #FileExtension, #FileDate, #Id)";
SqlCommand com = new SqlCommand(commnd, con);
com.Parameters.Add("#FileName", SqlDbType.VarChar).Value = model.FileName;
com.Parameters.Add("#FileData", SqlDbType.VarBinary).Value = stream.ToArray();
com.Parameters.Add("#FileExtension", SqlDbType.VarChar).Value = model.FileExtension;
com.Parameters.Add("#FileDate", SqlDbType.VarChar).Value = model.FileDate;
com.Parameters.Add("#Id", SqlDbType.NVarChar).Value = model.Id;
com.ExecuteScalar();
con.Close();
stream.CopyTo(new FileStream(filePath, FileMode.Create));
}
}
}
}
return View();
}
I have created an HTTP Client that sends data to my server. This data will query my server that will return a JSON object. How can I receive the JSON Object response from my server and insert it into my database?
The code below will send a ContactID to my server and my server will return a JSON Object How can I get the JSON Object from my server? What will I add to my code? I have added
var data = await response.Content.ReadAsStringAsync();
but I don't know how to proceed.
try
{
var db = DependencyService.Get<ISQLiteDB>();
var conn = db.GetConnection();
var sql = "SELECT * FROM tblUser WHERE ContactID = '" + contact + "'";
var getUser = conn.QueryAsync<UserTable>(sql);
var resultCount = getUser.Result.Count;
//Check if the user has been sync
if (resultCount < 1)
{
try
{
syncStatus.Text = "Syncing user to server...";
var link = Constants.requestUrl + "Host=" + host + "&Database=" + database + "&Contact=" + contact + "&Request=8qApc8";
string contentType = "application/json";
JObject json = new JObject
{
{ "ContactID", contact }
};
HttpClient client = new HttpClient();
var response = await client.PostAsync(link, new StringContent(json.ToString(), Encoding.UTF8, contentType));
var data = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
var userresult = JsonConvert.DeserializeObject<IList<UserData>>(content);
var count = userresult.Count;
for (int i = 0; i < count; i++)
{
try
{
syncStatus.Text = "Syncing user to server...";
var item = userresult[i];
var contactID = item.ContactID;
var userID = item.UserID;
var userPassword = item.UserPassword;
var userType = item.UserType;
var userStatus = item.UserStatus;
var lastSync = item.LastSync;
var serverUpdate = item.ServerUpdate;
var mobileUpdate = item.MobileUpdate;
var user = new UserTable
{
ContactID = Convert.ToInt32(contactID),
UserID = userID,
UserPassword = userPassword,
UserType = userType,
UserStatus = userStatus,
LastSync = lastSync,
ServerUpdate = serverUpdate,
MobileUpdate = mobileUpdate
};
await conn.InsertAsync(user);
}
catch (Exception ex)
{
Console.Write("Syncing user error " + ex.Message);
}
}
}
}
catch (Exception ex)
{
Console.Write("Syncing User Error " + ex.Message);
}
}
My PHP code will query my database with the ContactID received from Xamarin HTTP Client.
$json_str = file_get_contents('php://input');
$json_obj = json_decode($json_str);
$ContactID = $json_obj->ContactID;
$sql = "SELECT * FROM tblUser WHERE ContactID = '$ContactID'";
$result = mysqli_query($conn, $sql);
$count = mysqli_num_rows($result);
if($count > 0){
while ($row = #mysqli_fetch_array($result)) {
$decr = CryptRC4(FromHexDump($row['UserPassword']), $key);
$ar[] = array(
'ContactID' => $row['ContactID'],
'UserID' => $row['UserID'],
'UserPassword' => $decr,
'UserType' => $row['UserType'],
'UserStatus' => $row['UserStatus'],
'LastSync' => $sync,
'ServerUpdate' => $row['ServerUpdate'],
'MobileUpdate' => $row['MobileUpdate']
);
print json_encode($ar);
//Update LastSync DateTime
$sql = "UPDATE tblUser SET LastSync = '$sync' WHERE ContactID = '$ContactID'";
mysqli_query($conn, $sql);
}
}
Last statement in your example above gives list of json objects in string format.
var data = await response.Content.ReadAsStringAsync();
You need to convert that back to list of objects. To let your project know about definition of the object, create a plain class with public properties (Something like below)
public class UserLog
{
public int ContactId { get; set; }
public string Log { get; set; }
public DateTime LogDate { get; set; }
}
Add Newtonsoft.Json (by James Newton-King) Nuget package to your project so that you can work with json.
To convert content of the variable 'data' into list of UserLog objects, write code like
var list = NewtonsoftUtil<IList<UserLog>>.DeserializeObject(data);
(Add using Newtonsoft.Json; at top of the file)
Please let me know if this helps.
The answers above missing one important point -> efficiency.
There is no need to allocate a string in memory, especially if your JSON is big. Streams can do much better then strings:
// Read the response as stream
var stream = await response.Content.ReadAsStreamAsync();
// Use the next method for deserialization
T DeserializeJsonFromStream<T>(Stream stream)
{
if (stream == null || stream.CanRead == false)
return default(T);
using (var sr = new StreamReader(stream))
using (var jtr = new JsonTextReader(sr))
{
var js = new JsonSerializer();
return js.Deserialize<T>(jtr);
}
}
P.S.: Code example is bases on Json.NET.
P.S.S.: There are many good articles on this topic, I could recommend to get familiar with the next one.
Assuming that you have done everything correctly. In other words, You're be able to sent your contactID and get back a json.
Let's say your json structure is something like:
{"firstname" : "Doe",
"lastname" : "foo"
"age" : "27"}
One possible way to retrieve the data is as below:
using Newtonsoft.Json;
//after PostAsync()
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
JObject jContent = (JObject)JsonConvert.DeserializeObject(content);
string firstName = (string)jContent.GetValue("firstname")
string lastName = (string)jContent.GetValue("lastname");
int age = (int)jContent.GetValue("age");
}
Newtonsoft is available on Nuget. you need to install it if you have not done so.
Improved solution
What if your json has many key/values pairs like below:
{ key1 : value1,
key2 : value2,
key3 : value3,
...
key10 : value10}
Then it is not a good idea by doing :
string foo1 = (string)jContent.GetValue("key1");
string foo2 = (string)jContent.GetValue("key2");
//...
string foo10 = (string)jContent.GetValue("key10");
To handle this case, you can create a class:
public class Foo
{
public string Foo1 {get;set;}
public string Foo2 {get;set;}
//...
public string Foo2 {get;set;}
}
Then, you can do as simple as below:
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
Foo foo = JsonConvert.DeserializeObject<Foo>(content);
}
The improved solution referecnced from www.newtonsoft.com. Go there and check out other ways of using the library.
I am new on MVC3 and not familiar with the unit testing part. I have been trying to construct Datetime with exception handling from accepting 3 integer value but the it fails the unit testing. Im not sure i am doing it correctly or not.
This is the controller part:
public DateTime MakeDate(string dateString)
{
DateTime myDate;
if (DateTime.TryParseExact(dateString, "yyyy-MM-dd", new CultureInfo("en-US"), DateTimeStyles.None, out myDate))
{
return myDate;
}
return new DateTime();
}
And this is the unit Testing:
[TestMethod]
public void MakeDateConstructsADateTimeFromYearMonthAndDay()
{
//Arrange
var controller = new DateController();
var expected = new DateTime(2014, 6, 30);
//Act
var result = controller.MakeDate(2014, 6, 30);
//Assert
Assert.AreEqual<DateTime>(expected, result);
}
[TestMethod]
public void MakeDateReturnsDefaultDateTimeIfInputDataInvalid()
{
var controller = new DateController();
var expected = new DateTime();
//Act
//June has only 30 days so this will cause an exception
var result = controller.MakeDate(2014, 6, 31);
//Assert
Assert.AreEqual<DateTime>(expected, result);
}
Thanks in advance
string date = "2014-06-30";
DateTime datetime = DateTime.ParseExact(date, "yyyyMMdd", CultureInfo.InvariantCulture);
Your date string is not of the format you use in ParseExact.
You are using yyyyMMdd when you should be using yyyy-MM-dd.
The code fails because the string doesn't match the format.
Try changing your MakeDate function to something like this:
DateTime myDate;
if (DateTime.TryParseExact(dateString, "yyyy-MM-dd", new CultureInfo("en-US"), DateTimeStyles.None, out myDate))
{
return myDate;
}
return new DateTime();
Also, your MakeDate function doesn't use the dr parameter and you specify a date in format yyyy-MM-dd and use ParseExact with a different format (yyyyMMdd).
I'm developing an ASP.NET MVC3 project which has multi-language support. I hold all the words in database and select from it according to a Session value. At present I get the value as the following:
public ActionResult Index()
{
string lang = (string)System.Web.HttpContext.Current.Session["Language"];
if (lang == "Tr" || lang == null)
{
ViewBag.Admin = db.Words.Find(10).Tr;
}
else if(lang == "En")
{
ViewBag.Admin = db.Words.Find(10).En;
}
return View();
}
The present type of Word:
public class Word
{
public int ID { get; set; }
public string Tr { get; set; }
public string En { get; set; }
}
However, the number of languages will raise, and with the present method I need to add these by hand. What I want is getting the word's "Session" language form dynamically such as (in pseudo):
ViewBag.Admin = db.Words.Find(10)."Session[Language]";
I know it should be easy but couldn't find the appropriate keywords to find this. Any idea how can I achieve this?
EDIT: I just need a way to execute an SQL String like the following:
String lang = (string)System.Web.HttpContext.Current.Session["Language"];
ViewBag.MyWord = ExecuteSQL.("SELECT " + lang + " FROM Words WHERE ID = " + 10 + " ");
EDIT 2: I tried the following lines:
ViewBag.Admin = db.Words.SqlQuery("SELECT" +
(string)System.Web.HttpContext.Current.Session["Language"] +
"FROM Words WHERE ID=10");
However, the output for this is the query itself on the screen. (SELECT Tr FROM Words WHERE ID=10)
If you are using EF as your ORM you could do something like this:
int wordId = 10;
string lang = (string)System.Web.HttpContext.Current.Session["Language"];
var query = "SELECT " + lang + " FROM Words WHERE ID = {0}";
var word = context.Database.SqlQuery<string>(query, wordId).FirstOrDefault();
See here for more info on raw sql queries:
http://msdn.microsoft.com/en-us/data/jj592907.aspx
NOTE: The above could be open to sql injection, probably best to test that it's a 2 character language code before sending the sql request to the server.
You could do it by reflection. Just get the property by the language-key.
Here is some code:
Word word = ...
string lang = (string)System.Web.HttpContext.Current.Session["Language"];
PropertyInfo pi = typeof(Word).GetProperty(lang);
return pi.GetValue(word, null);
I did not at exception handling.
You could use an expression/delegate.
Write a methode returning the expression depending on Session["Language"].
private string GetLanguageStringByKey(int key){
return GetFuncByLanguage()(db.Words.Find(key));
}
private Func<Word,string> GetFuncByLanguage(){
string lang = (string)System.Web.HttpContext.Current.Session["Language"];
Func<Word, string> func;
switch(lang){
case "En":{
func = w => w.En;
break;
}
default:{
func = w => w.Tr;
break;
}
}
return func;
}
public ActionResult Index()
{
ViewBag.Admin = GetLanguageStringByKey(10);
return View();
}