public IHttpActionResult AddProduct([FromBody] ProductDetails pd) { if (ModelState.IsValid) { using (var db = new OMSEF()) { db.ProductDetails.Add(new ProductDetail { AvailableQuantity = pd.availableQuantity, Barcode = pd.barCode, Height = pd.height, Image = pd.image, Name = pd.name, Price = pd.price, SKU = pd.SKU, Weight = pd.weight }); db.SaveChanges(); } return(Ok()); } else { return(BadRequest()); } }
public IHttpActionResult AddRole([FromBody] UserRoles us) { using (var db = new OMSEF()) { db.UserRoles.Add(new UserRole { Name = us.name }); db.SaveChanges(); } return(Ok()); }
public IHttpActionResult DeleteRole(int id) { using (var db = new OMSEF()) { var userRole = db.UserRoles.Where(s => s.RoleId == id).FirstOrDefault(); if (userRole != null) { db.Entry(userRole).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } return(Ok()); } }
public IHttpActionResult DeleteAddress(int id) { using (var db = new OMSEF()) { var shippingAddress = db.ShippingAddresses.Where(s => s.AddressID == id).FirstOrDefault(); if (shippingAddress != null) { db.Entry(shippingAddress).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } return(Ok()); } }
public IHttpActionResult UpdateRole([FromBody] UserRoles us) { using (var db = new OMSEF()) { var userRole = db.UserRoles.Where(s => s.RoleId == us.roleId).FirstOrDefault(); if (userRole != null) { userRole.Name = us.name; } db.SaveChanges(); } return(Ok()); }
public IHttpActionResult AddAddress([FromBody] ShippingAddresses sa) { using (var db = new OMSEF()) { db.ShippingAddresses.Add(new ShippingAddress { Address1 = sa.Address1, Address2 = sa.Address2, City = sa.City, PinCode = sa.PinCode, State = sa.State }); db.SaveChanges(); } return(Ok()); }
public IHttpActionResult UpdateAddress([FromBody] ShippingAddresses sa) { using (var db = new OMSEF()) { var shippingAddress = db.ShippingAddresses.Where(s => s.AddressID == sa.AddressID).FirstOrDefault(); if (shippingAddress != null) { shippingAddress.Address1 = sa.Address1; shippingAddress.Address2 = sa.Address2; shippingAddress.City = sa.City; shippingAddress.PinCode = sa.PinCode; shippingAddress.State = sa.State; } db.SaveChanges(); } return(Ok()); }
public IHttpActionResult DeleteCustomer(int id) { if (id != null) { using (var db = new OMSEF()) { var customerDetail = db.CustomerDetails.Where(s => s.CustomerId == id).FirstOrDefault(); if (customerDetail != null) { db.Entry(customerDetail).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } return(Ok()); } } else { return(BadRequest()); } }
public IHttpActionResult AddCustomer([FromBody] CustomerDetails cd) { using (var db = new OMSEF()) { var customer = new CustomerDetail(); customer.CustomerAge = cd.CustomerAge; customer.CustomerEmail = cd.CustomerEmail; customer.CustomerGender = cd.CustomerGender; customer.CustomerPhone = cd.CustomerPhone; customer.Password = cd.Password; customer.CustomerName = cd.CustomerName; customer.RoleId = cd.UserRoleId; db.CustomerDetails.Add(customer); db.SaveChanges(); } return(Ok()); }
public IHttpActionResult UpdateCustomer([FromBody] CustomerDetails cd) { bool isUpdated = false; if (ModelState.IsValid) { using (var db = new OMSEF()) { var customerDetail = db.CustomerDetails.Where(s => s.CustomerId == cd.CustomerId).FirstOrDefault(); if (customerDetail != null) { customerDetail.CustomerAge = cd.CustomerAge; customerDetail.CustomerEmail = cd.CustomerEmail; customerDetail.CustomerGender = cd.CustomerGender; customerDetail.CustomerPhone = cd.CustomerPhone; customerDetail.Password = cd.Password; customerDetail.CustomerName = cd.CustomerName; customerDetail.RoleId = cd.UserRoleId; db.SaveChanges(); isUpdated = true; } } if (isUpdated) { return(Ok()); } else { return(BadRequest()); } } else { return(BadRequest()); } }
public IHttpActionResult UpdateProduct([FromBody] ProductDetails pd) { bool isUpdated = false; if (ModelState.IsValid) { using (var db = new OMSEF()) { var productdetail = db.ProductDetails.Where(s => s.ProductId == pd.productId).FirstOrDefault(); if (productdetail != null) { productdetail.AvailableQuantity = pd.availableQuantity; productdetail.Barcode = pd.barCode; productdetail.Height = pd.height; productdetail.Image = pd.image; productdetail.Name = pd.name; productdetail.Price = pd.price; productdetail.SKU = pd.SKU; productdetail.Weight = pd.weight; db.SaveChanges(); isUpdated = true; } } if (isUpdated) { return(Ok()); } else { return(BadRequest()); } } else { return(BadRequest()); } }