public JsonResult CreateProduct(CreateProductVM vm) { try { Product newProduct = new Product(); newProduct.Created = DateTime.Now; newProduct.CreatedBy = SessionManager.ActiveUser.Id; newProduct.Modified = DateTime.Now; newProduct.ModifiedBy = SessionManager.ActiveUser.Id; newProduct.IsActive = true; newProduct.BrandName = vm.BrandName; newProduct.Model = vm.Model; newProduct.Serial = vm.Serial; newProduct.WorkHeight = vm.WorkHeight; newProduct.WorkCapacity = vm.WorkCapacity; newProduct.Periodic = vm.Periodic; newProduct.State = vm.State; newProduct.Description = vm.Description; _ps.Insert(newProduct); return(Json(new { Result = true, Message = "Ürün Başarıyla Kaydedildi." })); } catch (Exception ex) { return(Json(new { Result = false, ex.Message })); } }
public IActionResult New(NewProductVm vm) { Product p = new Product(); p.CategoryId = vm.CategoryId; p.Discount = vm.Discount; p.ProductName = vm.ProductName; p.Price = vm.Price; p.ShortDescription = vm.ShortDescription; _productBs.Insert(p); return(Json(new { IsOk = true, ProductId = p.Id })); }