public List <ItemCategoryDto> GetAndEditItemCategory(int CategoryId, int IsActive) { List <ItemCategoryDto> lstItemCategoryDto = new List <ItemCategoryDto>(); SqlCommand cmd = new SqlCommand("GetAndEditItemCategory", connectionRepository.con); cmd.Parameters.AddWithValue("@CategoryId", CategoryId); cmd.Parameters.AddWithValue("@IsActive", IsActive); cmd.CommandType = CommandType.StoredProcedure; connectionRepository.con.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ItemCategoryDto itemCategoryDto = new ItemCategoryDto(); itemCategoryDto.GroupId = Convert.ToInt32(dr["GroupId"]); itemCategoryDto.GroupName = Convert.ToString(dr["GroupName"]); itemCategoryDto.CategoryId = Convert.ToInt32(dr["CategoryId"]); itemCategoryDto.CategoryName = Convert.ToString(dr["CategoryName"]); itemCategoryDto.CategoryDesc = Convert.ToString(dr["CategoryDesc"]); itemCategoryDto.CategoryImage = Convert.ToString(dr["CategoryImage"]); itemCategoryDto.CreatedBy = Convert.ToInt32(dr["CreatedBy"]); itemCategoryDto.CreatedDate = Convert.ToString(dr["CreatedDate"]); itemCategoryDto.ModifiedBy = Convert.ToInt32(dr["ModifiedBy"] != DBNull.Value ? dr["ModifiedBy"] : 0); itemCategoryDto.ModifiedDate = Convert.ToString(dr["ModifiedDate"] != DBNull.Value ? dr["ModifiedDate"] : ""); itemCategoryDto.IsActive = Convert.ToInt32(dr["IsActive"]); lstItemCategoryDto.Add(itemCategoryDto); } connectionRepository.con.Close(); return(lstItemCategoryDto); }
public async Task <int> AddItemCategoryAsync(ItemCategoryDto itemCategory) { if (itemCategory == null) { return(0); } using (var uow = UnitOfWorkProvider.Create()) { var item = await itemService.GetAsync(itemCategory.ItemID); if (item == null) { return(0); } var category = await categoryService.GetAsync(itemCategory.CategoryID); if (category == null) { return(0); } var res = itemCategoryService.Create(itemCategory); await uow.Commit(); return(res.Id); } }
public async Task <string> PostItemCategory([FromBody] ItemCategoryDto itemCategory) { if (itemCategory == null || !ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var itemCatId = await ModifyAuctionsFacade.AddItemCategoryAsync(itemCategory); if (itemCatId == 0) { throw new HttpResponseException(HttpStatusCode.BadRequest); } return($"Added category {itemCategory.CategoryID} to item {itemCategory.ItemID }."); }
public async Task <string> PutItemCategory(int id, [FromBody] ItemCategoryDto itemCategory) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var success = await ModifyAuctionsFacade.UpdateItemCategoryAsync(itemCategory); if (!success) { throw new HttpResponseException(HttpStatusCode.NotFound); } return($"Updated itemCategory with id: {id}"); }
public ActionResult SaveItemCategory() { try { ItemCategoryDal itemCategoryDal = new ItemCategoryDal(); ItemCategoryDto itemCategoryDto = new ItemCategoryDto(); itemCategoryDto.CategoryId = Convert.ToInt32(System.Web.HttpContext.Current.Request["CategoryId"] == "" ? "0" : System.Web.HttpContext.Current.Request["CategoryId"]); string Message, fileName, actualFileName; Message = fileName = actualFileName = string.Empty; if (Request.Files.Count > 0) { var fileContent = Request.Files[0]; if (fileContent != null && fileContent.ContentLength > 0) { actualFileName = fileContent.FileName; fileName = Guid.NewGuid() + Path.GetExtension(fileContent.FileName); itemCategoryDto.CategoryImage = fileName; } fileContent.SaveAs(Path.Combine(Server.MapPath("~/UploadImages/"), fileName)); } else { fileName = ""; if (itemCategoryDto.CategoryId > 0) { dynamic imgFile = itemCategoryDal.GetAndEditItemCategory(itemCategoryDto.CategoryId, 1); itemCategoryDto.CategoryImage = Convert.ToString(imgFile[0].CategoryImage); } else { itemCategoryDto.CategoryImage = fileName; } } itemCategoryDto.GroupId = Convert.ToInt32(System.Web.HttpContext.Current.Request["GroupId"]); itemCategoryDto.CategoryName = System.Web.HttpContext.Current.Request["CategoryName"]; itemCategoryDto.CategoryDesc = System.Web.HttpContext.Current.Request["CategoryDesc"]; itemCategoryDto.CreatedBy = Convert.ToInt32(Session["AdminId"]); itemCategoryDto.ModifiedBy = Convert.ToInt32(Session["AdminId"]); itemCategoryDto.IsActive = 1; int i = itemCategoryDal.SaveItemCategory(itemCategoryDto); return(Json(i, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }
public async Task <List <ItemDto> > GetItems(ItemCategoryDto categoryDto) { var response = await Client.GetAsync( $"api/beta/companies({CompanyId})/items?$filter=itemCategoryCode eq '{categoryDto.Code}'"); if (!response.IsSuccessStatusCode) { throw new NavClientException(response.ReasonPhrase); } var stringResponse = await response.Content.ReadAsStringAsync(); var context = JsonConvert.DeserializeObject <ItemContextDto>(stringResponse); return(context.Value); }
public async Task <bool> UpdateItemCategoryAsync(ItemCategoryDto itemCategory) { if (itemCategory == null) { return(false); } using (var uow = UnitOfWorkProvider.Create()) { if (await itemCategoryService.GetAsync(itemCategory.Id) == null) { return(false); } await itemCategoryService.Update(itemCategory); await uow.Commit(); return(true); } }
public async Task Create() { try { if (!Validate()) { return; } var item = new ItemCategoryDto { AddedOn = DateTime.Now, Name = GetItemName(), Priority = (int)GetPriority(), CategoryId = _catDVM.Category.Id, CategoryName = _catDVM.Category.Name }; _catDVM.AddItemAPI(item); Success = true; Hide(); } catch (Exception e) { Console.WriteLine($"Something went wrong: {e}"); this.TxtBottomError.Text = e.Message; } }
public List <ItemCategoryDto> GetItemCategoryByGroupId(int GroupId) { List <ItemCategoryDto> lstItemCategoryDto = new List <ItemCategoryDto>(); SqlCommand cmd = new SqlCommand("GetItemCategoryByGroupId", connectionRepository.con); cmd.Parameters.AddWithValue("@GroupId", GroupId); cmd.CommandType = CommandType.StoredProcedure; connectionRepository.con.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ItemCategoryDto itemCategoryDto = new ItemCategoryDto(); itemCategoryDto.GroupId = Convert.ToInt32(dr["GroupId"]); itemCategoryDto.CategoryId = Convert.ToInt32(dr["CategoryId"]); itemCategoryDto.CategoryName = Convert.ToString(dr["CategoryName"]); lstItemCategoryDto.Add(itemCategoryDto); } connectionRepository.con.Close(); return(lstItemCategoryDto); }
public int SaveItemCategory(ItemCategoryDto itemCategoryDto) { try { SqlCommand cmd = new SqlCommand("SaveAndUpdateItemCategory", connectionRepository.con); cmd.Parameters.AddWithValue("@CategoryId", itemCategoryDto.CategoryId); cmd.Parameters.AddWithValue("@GroupId", itemCategoryDto.GroupId); cmd.Parameters.AddWithValue("@CategoryName", itemCategoryDto.CategoryName); cmd.Parameters.AddWithValue("@CategoryDesc", itemCategoryDto.CategoryDesc); cmd.Parameters.AddWithValue("@CategoryImage", itemCategoryDto.CategoryImage); cmd.Parameters.AddWithValue("@CreatedBy", itemCategoryDto.CreatedBy); cmd.Parameters.AddWithValue("@ModifiedBy", itemCategoryDto.ModifiedBy); cmd.Parameters.AddWithValue("@IsActive", itemCategoryDto.IsActive); cmd.CommandType = CommandType.StoredProcedure; connectionRepository.con.Open(); int i = cmd.ExecuteNonQuery(); connectionRepository.con.Close(); return(i); } catch (Exception ex) { throw ex; } }
public async Task <ItemCategoryDto> CreateItemCategory([FromBody] ItemCategoryDto dto) { return(await ItemCategoryAppService.CreateAsync(dto)); }
public HomeContent GetHomeContent(string authorization) { var itemFood = new ItemFoodDto() { FoodId = 1, RestaurantId = 1, FoodCost = 34000, FoodName = "Homestyle Crispy Chicken", RestaurantName = "McDonald's", FoodImage = "https://cdn.shopify.com/s/files/1/0269/5967/5490/products/6.2.jpg" }; var itemRestaurant = new ItemRestaurantHoriDto() { RestaurantId = 1, RestaurantName = "McDonald's® (Adams & Wells)", RestaurantImage = "http://52.187.117.17/nwork-api/image/0b0b6588-52d3-42d1-a4e8-6b949561957f.jfif" }; var itemRestaurant1 = new ItemRestaurantHoriDto() { RestaurantId = 1, RestaurantName = "McDonald's® (Adams & Wells)", RestaurantImage = "https://mcdonalds.vn/uploads/2018/gacay_squared-rev.jpg" }; var itemCollection1 = new ItemCollectionDto() { CollectionId = 1, CollectionTitle = "Let's Eat Pizza With Emily", CollectionSubtitle = "Delicious and nutritious", CollectionImage = "https://scontent.fdad3-2.fna.fbcdn.net/v/t1.15752-9/s2048x2048/149581589_748881315744891_4814137521680383224_n.jpg?_nc_cat=107&ccb=3&_nc_sid=ae9488&_nc_ohc=K_qXkTXFt2MAX8ua8Or&_nc_ht=scontent.fdad3-2.fna&tp=7&oh=e99582684eb28ce343bd3268883d2a2e&oe=605267CC" }; var itemHomeCollection1 = new ItemListHomeDto() { Id = 1, Title = "Delicious food at Chicago", Subtitle = "Order now to get your meal served in minutes", Type = "collection", ListCollection = new List <ItemCollectionDto>() { itemCollection1, itemCollection1, itemCollection1, itemCollection1, itemCollection1, itemCollection1 } }; var itemHomeRestaurant = new ItemListHomeDto() { Id = 2, Title = "Tasty snack near you", Subtitle = "Too good to be missed get the deals now!", Type = "restaurant", ListRestaurant = new List <ItemRestaurantHoriDto>() { itemRestaurant, itemRestaurant1, itemRestaurant, itemRestaurant1, itemRestaurant, itemRestaurant1 } }; var itemHomeFood = new ItemListHomeDto() { Id = 3, Title = "Hot Item Today", Subtitle = "Order now to get your meal served in minutes", Type = "food", ListFood = new List <ItemFoodDto>() { itemFood, itemFood, itemFood, itemFood, itemFood, itemFood, itemFood, itemFood } }; var itemBanner = new ItemBannerDto() { Id = 1, Image = "http://channel.mediacdn.vn/2019/1/20/image005-15479948829561514367436.jpg" }; var itemCategory = new ItemCategoryDto() { CategoryId = 1, Title = "Bread", Image = "http://52.187.117.17/nwork-api/image/6bd41860-95f3-4b20-a42c-2a6aceadf54e.png" }; var itemCategory2 = new ItemCategoryDto() { CategoryId = 1, Title = "Hamburger", Image = "http://52.187.117.17/nwork-api/image/610431f9-32e7-4aad-8b24-88d89668209c.jpg" }; var itemCategory3 = new ItemCategoryDto() { CategoryId = 1, Title = "Cake", Image = "http://52.187.117.17/nwork-api/image/9d63bd85-a3cc-4e48-8039-bd2c45bcbdc8.png" }; var itemRestaurantVerti = new ItemRestaurantVertiDto() { RestaurantId = 2, RestaurantName = "KFC Camberwell - Church Street", RestaurantType = "Fried Chicken - American - Fast Food", RestaurantImage = "https://d1ralsognjng37.cloudfront.net/a7002177-10a0-4cee-98e3-007e5805fc7e.jpeg", RestaurantRate = 4.5, DeliveryTime = 23, Distance = 5.0 }; var contentHome = new HomeContent() { ListBanner = new List <ItemBannerDto>() { itemBanner, itemBanner, itemBanner, itemBanner }, ListCategory = new List <ItemCategoryDto>() { itemCategory2, itemCategory2, itemCategory2, itemCategory2, itemCategory2, itemCategory2 }, ListHome = new List <ItemListHomeDto>() { itemHomeCollection1, itemHomeRestaurant, itemHomeRestaurant }, MoreRestaurant = new List <ItemRestaurantVertiDto>() { itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti } }; return(contentHome); }
public bool AddItemCategory(ItemCategoryDto itemDto) { if (itemDto != null) { using (EAharaDB context = new EAharaDB()) { if (itemDto.Id > 0) { var data = context.ItemCategories.FirstOrDefault(x => x.Id == itemDto.Id); if (data != null) { data.Name = itemDto.Name; data.Priority = itemDto.Priority; // data.Image = itemDto.Image; context.Entry(data).Property(x => x.Name).IsModified = true; //context.Entry(data).Property(x => x.Image).IsModified = true; if (itemDto.Image != null && itemDto.Image != "" && data.Image != itemDto.Image && !itemDto.Image.Contains("http")) { Guid id = Guid.NewGuid(); var imgData = itemDto.Image.Substring(itemDto.Image.IndexOf(",") + 1); byte[] bytes = Convert.FromBase64String(imgData); Image image; using (MemoryStream ms = new MemoryStream(bytes)) { image = Image.FromStream(ms); } Bitmap b = new Bitmap(image); string filePath = System.Web.HttpContext.Current.Server.MapPath("~") + "UploadedFiles\\" + id + ".jpg"; b.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg); data.Image = string.Concat("UploadedFiles\\" + id + ".jpg"); context.Entry(data).Property(x => x.Image).IsModified = true; } context.SaveChanges(); return(true); } return(false); } else { ItemCategory item = new ItemCategory(); item.Name = itemDto.Name; item.Priority = itemDto.Priority; item.IsActive = true; context.ItemCategories.Add(item); if (itemDto.Image != null && itemDto.Image != "") { Guid id = Guid.NewGuid(); var imgData = itemDto.Image.Substring(itemDto.Image.IndexOf(",") + 1); byte[] bytes = Convert.FromBase64String(imgData); Image image; using (MemoryStream ms = new MemoryStream(bytes)) { image = Image.FromStream(ms); } Bitmap b = new Bitmap(image); string filePath = System.Web.HttpContext.Current.Server.MapPath("~") + "UploadedFiles\\" + id + ".jpg"; b.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg); item.Image = string.Concat("UploadedFiles\\" + id + ".jpg"); } context.SaveChanges(); return(true); } } } return(false); }
public List <ItemCategoryDto> getShopItemsForFirstLoad(long id) { List <ItemCategoryDto> DtoList; using (EAharaDB context = new EAharaDB()) { var shop = context.Shops.FirstOrDefault(x => x.Id == id); var data = context.ItemCategories.Where(x => x.IsActive == true && context.Items.Where(y => y.ItemCategoryId == x.Id && y.IsActive && y.Shop.ShopCategoryId == shop.ShopCategoryId && y.ShopId == id).Count() > 0) .Select(x => new ItemCategoryDto { Id = x.Id, IsActive = x.IsActive, Priority = x.Priority, Name = x.Name, Image = x.Image, Items = context.Items.Where(y => y.IsActive && y.ShopId == id && y.ItemCategoryId == x.Id).Select( y => new ItemDto { Id = y.Id, IsActive = y.IsActive, Name = y.Name, OfferId = y.OfferId, OfferPrice = y.OfferPrice, Price = y.Price, Image = y.Image, InActive = y.InActive, Preference = y.Preference, Quantity = 1, Offer = new OfferDto { Id = y.Offer != null ? y.Offer.Id : 0, Image = y.Offer != null ? y.Offer.Image : "", Tittle = y.Offer != null ? y.Offer.Tittle : "", Percentage = y.Offer != null ? y.Offer.Percentage : 0, }, }).OrderBy(y => y.OfferPrice).ToList(), }).ToList(); DtoList = data; var dataoffer = context.Items.Where(x => x.IsActive && x.ShopId == id && x.OfferId != null) .Select(x => new ItemDto { Id = x.Id, Name = x.Name, IsActive = x.IsActive, Image = x.Image, TagLine = x.TagLine, Description = x.Description, Price = x.Price, ShopId = x.ShopId, ItemCategoryId = x.ItemCategoryId, OfferId = x.OfferId, OfferPrice = x.OfferPrice, InActive = x.InActive, Preference = x.Preference, Quantity = 1, Offer = new OfferDto { Image = x.Offer != null ? x.Offer.Image : "", Percentage = x.Offer != null ? x.Offer.Percentage : 0, Tittle = x.Offer != null ? x.Offer.Tittle : "", Id = x.Offer != null ? x.Offer.Id : 0, }, Shop = new ShopDto { Name = x.Shop.Name, Id = x.Shop.Id, DeliveryCharge = x.Shop.DeliveryCharge, }, ItemsCategory = new ItemCategoryDto { Name = x.ItemsCategory.Name, Id = x.ItemsCategory.Id, } }).OrderBy(x => x.OfferPrice).ToList(); if (dataoffer.Count() > 0) { ItemCategoryDto temp = new ItemCategoryDto(); temp.Name = "Today's Offers"; temp.Priority = 0; temp.Items = new List <ItemDto>(); foreach (var offer in dataoffer) { temp.Items.Add(offer); } DtoList.Add(temp); } } return(DtoList); }