public ResponseData AddByEntity(ActionTypeViewModel data) { using (SATEntities db = new SATEntities()) { ResponseData result = new Models.ResponseData(); try { tb_Action_Type model = new tb_Action_Type(); model.ActID = data.ActID; model.ActName = data.ActName; model.ActType = data.ActType; model.ActPos = data.ActPos; model.CreateBy = UtilityService.User.UserID; model.CreateDate = DateTime.Now; model.ModifyBy = UtilityService.User.UserID; model.ModifyDate = DateTime.Now; db.tb_Action_Type.Add(model); db.SaveChanges(); } catch (Exception) { } return(result); } }
public ActionResult ActionTypeDetail(int?id) { ActionTypeViewModel model = new ActionTypeViewModel(); if (id.HasValue) { model = new ActionTypeRepository().GetByID((int)id); } return(PartialView("_ActionType", model)); }
public JsonResult SaveActionType(ActionTypeViewModel model) { ResponseData result = new Models.ResponseData(); if (model.ActID != 0) { result = new ActionTypeRepository().UpdateByEntity(model); } else { result = new ActionTypeRepository().AddByEntity(model); } return(Json(result, JsonRequestBehavior.AllowGet)); }
// GET: ActionTypes/Details/5 public async Task <IActionResult> Details(Guid id) { if (id == null) { return(NotFound()); } var item = await _context.LookupActionTypes.AsNoTracking() .Where(m => m.Id == id) .SingleOrDefaultAsync(); if (item == null) { return(NotFound()); } var model = new ActionTypeViewModel(item); return(View(model)); }
public ResponseData UpdateByEntity(ActionTypeViewModel newdata) { using (SATEntities db = new SATEntities()) { ResponseData result = new Models.ResponseData(); try { var data = db.tb_Action_Type.Single(x => x.ActID == newdata.ActID); data.ActName = newdata.ActName; data.ActType = newdata.ActType; data.ActPos = newdata.ActPos; data.ModifyBy = UtilityService.User.UserID; data.ModifyDate = DateTime.Now; db.SaveChanges(); } catch (Exception) { } return(result); } }