Esempio n. 1
0
        public async Task <IActionResult> Create(ClientTypeVM 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);
            await _context.SaveChangesAsync();

            return(PartialView("_Create", model));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create()
        {
            ClientTypeVM cType = new ClientTypeVM();

            return(PartialView("_Create", cType));
        }