public ActionResult Create(CoolAppModel model) { CoolApp coolApp = _coolAppService.GetById(model.Id); if (coolApp != null) { model.Errors.Add(_languageService.GetLocaleString("CoolApp Already Exists")); return(Json(model)); } if (_coolAppService.GetAll().Where(k => k.Id == model.Id && k.CoolComId == model.CompanyId).Count() > 0) { model.Errors.Add(_languageService.GetLocaleString("CoolApp Already Exists")); return(Json(model)); } if (ModelState.IsValid) { coolApp = new CoolApp(); coolApp.CoolComId = model.CompanyId; coolApp.CoolCompanyId = model.CoolCompanyId; coolApp.AppCode = model.AppCode; _coolAppService.Insert(coolApp); model.SuccessMessage = _languageService.GetLocaleString("CoolApp Created"); } else { model.Errors.Add("Check fields for editing"); } return(Json(model)); }
public ActionResult Create() { CoolAppModel model = new CoolAppModel(); model = PrepareCoolAppModel(model, new CoolApp(), true); return(View(model)); }
private CoolAppListModel PrepareCoolAppListModel(CoolAppListModel model, List <CoolApp> coolApps) { foreach (var c in coolApps) { CoolAppModel ccm = new CoolAppModel(); ccm = PrepareCoolAppModel(ccm, c); model.Items.Add(ccm); } return(model); }
public ActionResult Edit(string Id) { CoolAppModel model = new CoolAppModel(); var coolUser = _coolAppService.GetById(Id); if (coolUser == null) { model.Errors.Add(_languageService.GetLocaleString("CoolApp not found")); return(View(model)); } model = PrepareCoolAppModel(model, coolUser, true); return(View(model)); }
private CoolAppModel PrepareCoolAppModel(CoolAppModel model, CoolApp coolApp, bool fillAvailableCompanies = false) { model.Id = coolApp.Id; model.AppCode = coolApp.AppCode; model.CompanyId = coolApp.CoolComId; model.CoolCompanyId = coolApp.CoolCompanyId; model.Image = "<span class=\"avatar avatar-online\"><img src=\"" + _erpManagerSettings.AppPicturePath + coolApp.Id + "\"/></span>"; if (fillAvailableCompanies) { model.AvailableCompanies = _coolComService.GetAll().Select(k => new SelectListItem { Text = k.Id, Value = k.Id }).ToList(); } return(model); }
public ActionResult Delete(string Id) { CoolAppModel model = new CoolAppModel(); var coolUser = _coolAppService.GetById(Id); if (coolUser != null) { _coolAppService.Delete(Id); } else { model.Errors.Add(_languageService.GetLocaleString("CoolApp Couldn't found")); } model.SuccessMessage = _languageService.GetLocaleString("CoolApp Deleted successfully"); return(Json(model)); }
public ActionResult Edit(CoolAppModel model) { var coolApp = _coolAppService.GetById(model.Id); if (coolApp == null) { model.Errors.Add(_languageService.GetLocaleString("CoolApp not found")); return(Json(model)); } if (ModelState.IsValid) { coolApp.CoolComId = model.CompanyId; coolApp.CoolCompanyId = model.CoolCompanyId; coolApp.AppCode = model.AppCode; _coolAppService.Update(coolApp); model.SuccessMessage = _languageService.GetLocaleString("CoolApp Updated"); } else { model.Errors.Add("Check fields for editing"); } return(Json(model)); }