public async Task <ActionResult> Create(TemplatePartModel templatepart) { if (ModelState.IsValid) { var templatepartModel = new TemplatePartModel { TemplatePartId = templatepart.TemplatePartId, TemplatePartName = templatepart.TemplatePartName, IsActive = templatepart.IsActive, HTMLPart = templatepart.HTMLPart, PlainTextPart = templatepart.PlainTextPart, UserId = CurrentUser.UserId, CompanyId = CurrentUser.CompanyId }; ResponseModel response = new ResponseModel(); if (templatepartModel.TemplatePartId != 0) { response = await _templatePartRepo.AddUpdateDeleteTemplatePart(templatepartModel, 'U'); } else { response = await _templatePartRepo.AddUpdateDeleteTemplatePart(templatepartModel, 'I'); } _templatePartRepo.Save(); TempData["response"] = response; return(RedirectToAction("Index")); } else { return(View(templatepart)); } }
public async Task <ResponseModel> AddUpdateDeleteTemplatePart(TemplatePartModel templatePartModel, char action) { List <SqlParameter> sp = new List <SqlParameter>(); SqlParameter param = new SqlParameter("@TemplatePartId", ToDBNull(templatePartModel.TemplatePartId)); sp.Add(param); param = new SqlParameter("@TemplatePartName", (object)templatePartModel.TemplatePartName); sp.Add(param); param = new SqlParameter("@HTMLPart", (object)templatePartModel.HTMLPart); sp.Add(param); param = new SqlParameter("@PlainTextPart", (object)templatePartModel.PlainTextPart); sp.Add(param); param = new SqlParameter("@User", (object)templatePartModel.UserId); sp.Add(param); param = new SqlParameter("@IsActive", (object)templatePartModel.IsActive); sp.Add(param); param = new SqlParameter("@Action", (object)action); sp.Add(param); param = new SqlParameter("@CompId", ToDBNull(templatePartModel.CompanyId)); sp.Add(param); var sql = "USPTemplatePartADDUPDATE @TemplatePartId,@TemplatePartName,@HTMLPart,@PlainTextPart,@User,@IsActive,@Action,@CompId"; var res = await _context.Database.SqlQuery <ResponseModel>(sql, sp.ToArray()).FirstOrDefaultAsync(); if (res.ResponseCode == 0) { res.IsSuccess = true; } return(res); }
public async Task <ActionResult> Create() { var templatepartmodel = new TemplatePartModel(); return(View(templatepartmodel)); }