[Authorize(Roles = "Admin,Personnel")] //Personnel public ActionResult Update(string Id, string Name, string NameEn, string content, string contentEn, string Date_event_start, string Date_event_end, string Price_event, string Ord, string Active) { Even_Date_Model model = new Even_Date_Model();//gọi model data model.Id = Convert.ToInt32(Id); model.Name = Name; model.NameEn = NameEn; model.content = content; model.contentEn = contentEn; model.Price_event = Convert.ToInt32(Price_event); model.Ord = Convert.ToInt32(Ord); model.Active = Convert.ToBoolean(Active); //event date start if (Date_event_start != "") { DateTime Date_event_start_string = DateTime.ParseExact(Date_event_start, @"d/M/yyyy", System.Globalization.CultureInfo.InvariantCulture); model.Date_event_start = Date_event_start_string; } else { model.Date_event_start = null; } //evevnt date end if (Date_event_end != "") { DateTime Date_event_end_string = DateTime.ParseExact(Date_event_end, @"d/M/yyyy", System.Globalization.CultureInfo.InvariantCulture); model.Date_event_end = Date_event_end_string; } else { model.Date_event_end = null; } if (connect_entity.Even_Date.FirstOrDefault (x => x.Name == model.Name && x.Id != model.Id) == null) // kiểm tra không được trùng tên { Connect.Update(model); //gọi service lưu Resurt = 1; } else { Resurt = 0; } return(Json(Resurt, JsonRequestBehavior.AllowGet)); }
public IList <Even_Date_Model> GetId(Even_Date_Model model) { IList <Even_Date_Model> result = new List <Even_Date_Model>(); result = Connect_Enttity.Even_Date.Where(x => x.Id == model.Id).Select(x => new Even_Date_Model { Id = x.Id, Name = x.Name, NameEn = x.NameEn, content = x.content, contentEn = x.contentEn, Date_event_start = (DateTime)(x.Date_event_start), Date_event_end = (DateTime)(x.Date_event_end), Price_event = (int)(x.Price_event), Ord = (int)(x.Ord), Active = (bool)(x.Active) }).ToList(); return(result); }
public void Create(Even_Date_Model model) { var data = Connect_Enttity.Even_Date.FirstOrDefault(x => x.Id == model.Id); if (data == null) { var entity = new Even_Date(); entity.Name = model.Name; entity.NameEn = model.NameEn; entity.content = model.content; entity.contentEn = model.contentEn; entity.Price_event = model.Price_event; if (model.Date_event_start == null) { entity.Date_event_start = null; } else { entity.Date_event_start = Convert.ToDateTime(model.Date_event_start); } if (model.Date_event_end == null) { entity.Date_event_end = null; } else { entity.Date_event_end = Convert.ToDateTime(model.Date_event_end); } entity.Ord = (int)(model.Ord); entity.Active = (bool)(model.Active); Connect_Enttity.Even_Date.Add(entity); Connect_Enttity.SaveChanges(); Dispose(); } }
public void Update(Even_Date_Model model) { var data = Connect_Enttity.Even_Date.FirstOrDefault(x => x.Id == model.Id); if (data != null) { data.Name = model.Name; data.NameEn = model.NameEn; data.content = model.content; data.contentEn = model.contentEn; data.Price_event = model.Price_event; if (model.Date_event_start == null) { data.Date_event_start = null; } else { data.Date_event_start = Convert.ToDateTime(model.Date_event_start); } if (model.Date_event_end == null) { data.Date_event_end = null; } else { data.Date_event_end = Convert.ToDateTime(model.Date_event_end); } data.Ord = (int)(model.Ord); data.Active = (bool)(model.Active); Connect_Enttity.SaveChanges(); Dispose(); } }
public IEnumerable <Even_Date_Model> ReadID(Even_Date_Model model) { return(GetId(model)); }