public string addItemMaster(itemDetailsDataContract ItmDetails) { try { var checkIDExist = OME.ItemDetails.Where(x => x.Item_code == ItmDetails.Item_code).Any(); if (checkIDExist) { return("Duplicate"); } ItemDetail EF = new ItemDetail(); EF.Item_code = ItmDetails.Item_code; //EF.Item_ID = Convert.ToInt32(ItmDetails.Item_ID); EF.Item_Name = ItmDetails.Item_Name; EF.Description = ItmDetails.Description; EF.Short_Description = ItmDetails.Short_Description; EF.Item_Price = ItmDetails.Item_Price; EF.Image_Name = ItmDetails.Image_Name; EF.AddedBy = ItmDetails.AddedBy; EF.ShippingCost = ItmDetails.Shipping_Price; EF.Status = ItmDetails.Status; EF.TaxAmount = ItmDetails.Tax_Amount; EF.CreatedDate = DateTime.UtcNow; OME.ItemDetails.Add(EF); OME.SaveChanges(); } catch (Exception ex) { //throw new Exception(ex.Message); return("Error"); } return("Ok"); }
public itemDetailsDataContract GetItemForAddtocart(string itemCode) { long itemID; bool result = Int64.TryParse(itemCode, out itemID); if (!result) { itemID = 0; } itemDetailsDataContract model = new itemDetailsDataContract(); model = OME.ItemDetails.Where(x => x.Item_ID == itemID || x.Item_code == itemCode).ToList().Select(x => new itemDetailsDataContract { Item_ID = Convert.ToInt64(x.Item_ID), Item_Name = x.Item_Name, Item_Price = x.Item_Price, Description = x.Description, Image_Name = x.Image_Name, AddedBy = x.AddedBy, Status = x.Status ?? "0", Shipping_Price = x.ShippingCost ?? 0, Tax_Amount = x.TaxAmount ?? 0, Item_code = x.Item_code ?? "N/A", Short_Description = x.Short_Description }).SingleOrDefault(); return(model); }
public HttpResponseMessage Post(itemDetailsDataContract ItemDetails) { ShoppingcartModel Shoppingmodel = new ShoppingcartModel(); string json = JsonConvert.SerializeObject(Shoppingmodel.addItemMaster(ItemDetails)); return(Request.CreateResponse(HttpStatusCode.OK, json)); }
//public string GetImagename(string Itemcode) //{ // try // { // var image = OME.ItemDetails.Where(y => y.Item_code == Itemcode).Select(y => y.Image_Name).FirstOrDefault().ToString(); // return image; // } // catch (Exception ex) // { // return ""; // } //} public itemDetailsDataContract GetItemDetail(int?itemID) { itemDetailsDataContract model = new itemDetailsDataContract(); model = OME.ItemDetails.Where(x => x.Item_ID == itemID).ToList().Select(x => new itemDetailsDataContract { Item_ID = Convert.ToInt64(x.Item_ID), Item_Name = x.Item_Name, Item_Price = x.Item_Price, Description = x.Description, Image_Name = x.Image_Name, AddedBy = x.AddedBy, Status = x.Status ?? "0", Shipping_Price = x.ShippingCost ?? 0, Tax_Amount = x.TaxAmount ?? 0, Item_code = x.Item_code ?? "N/A", Short_Description = x.Short_Description }).SingleOrDefault(); return(model); }
public ActionResult Edit(HttpPostedFileBase file, itemDetailsDataContract model) { var id = Convert.ToInt32(model.Item_ID); try { string Message, fileName = string.Empty; if (file != null) { fileName = file.FileName; try { file.SaveAs(Path.Combine(Server.MapPath("~/images/Products"), fileName)); Message = "File uploaded"; } catch (Exception) { Message = "File upload failed! Please try again"; } } db_AirborneEntities OEM = new db_AirborneEntities(); var GetProductDetails = OEM.ItemDetails.Where(x => x.Item_ID == id).FirstOrDefault(); GetProductDetails.Item_code = model.Item_code; GetProductDetails.Item_Name = model.Item_Name; GetProductDetails.Item_Price = model.Item_Price; GetProductDetails.Image_Name = (!string.IsNullOrEmpty(fileName)) ? fileName : model.Image_Name; GetProductDetails.Status = model.Status; GetProductDetails.Description = model.Description; GetProductDetails.Short_Description = model.Short_Description; GetProductDetails.ShippingCost = model.Shipping_Price; GetProductDetails.TaxAmount = model.Tax_Amount; OEM.SaveChanges(); } catch (Exception ex) { return(RedirectToAction("Index", "StoreManager", new { area = "Admin" })); } return(RedirectToAction("Index", "StoreManager", new { area = "Admin" })); }