示例#1
0
        public async Task <ActionResult> Create(ModelPCB modelView)
        {
            if (ModelState.IsValid)
            {
                ModelPCB model = new ModelPCB
                {
                    ModelID      = Guid.NewGuid().ToString(),
                    ModelName    = modelView.ModelName,
                    CreatedBy    = User.Identity.Name,
                    DateCreated  = DateTime.Now,
                    Quantity     = modelView.Quantity,
                    SerialNo     = modelView.SerialNo,
                    CustomerName = modelView.CustomerName,
                };

                try
                {
                    await modelService.InsertAsync(model);
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("ModelName", ex.Message);
                }
                return(RedirectToAction("Index"));
            }
            return(PartialView());
        }