public IActionResult Create(ClientTypeOwnerVM model) { if (!ModelState.IsValid) { Response.StatusCode = 400; return(PartialView("_Create", model)); } ClientType clientType = new ClientType(); if (clientType == null) { return(PartialView("_IndexPArtial", clientType)); } clientType.Name = model.Name; clientType.Description = model.Description; clientType.Discount = model.Discount; clientType.IsDeleted = false; var item = _context.ClientType.Where(c => c.Name == model.Name).Count(); model.ErrorMessage = _context.ClientType.Where(x => x.Name == model.Name).FirstOrDefault() != null ? "This client type already exist" : ""; if (model.ErrorMessage != String.Empty) { Response.StatusCode = 400; return(PartialView("_Create", model)); } _context.ClientType.Add(clientType); _context.SaveChanges(); return(PartialView("_Create", model)); }
public IActionResult Create() { ClientTypeOwnerVM cType = new ClientTypeOwnerVM(); return(PartialView("_Create", cType)); }