public static void AddNewRestaurent(ListItemLocal source) { using (var dbContext = new DeliversEntities()) { DbGeography loc = null; if (!String.IsNullOrEmpty(source.Location) && source.Location != "") { var latlng = source.Location.Split('_'); if (latlng.Length == 2) { loc = CommonService.ConvertLatLonToDbGeography(latlng[1], latlng[0]); // lat _ lng } } var dbObj = new ListItem { Location = loc, Name = source.Name, Description = source.Description, Phone = source.Phone, LogoImage = source.LogoImage, LastEdit = DateTime.Now, BgImage = source.BgImage, Address = source.Address, Rating = source.Rating, Type = source.Type, Id = source.Id, Status = source.Status, Cords = loc, CreationDate = DateTime.Now }; dbContext.ListItems.Add(dbObj); dbContext.SaveChanges(); } }
public static async Task <ListItemLocal> DetailsAsync(long id) { ListItemLocal listItemLocal = null; using (var dbContext = new DeliversEntities()) { ListItem listItem = await dbContext.ListItems.FindAsync(id); listItemLocal = listItem.MapListItem(); } return(listItemLocal); }
public ActionResult PartnerCreate(ListItemLocal model) { model.Id = ListService.Create(model); var relativePath = ConfigurationManager.AppSettings["saveImagesIn"]; if (model.Logo != null) { Functions.SaveFile(model.Logo, relativePath, Server.MapPath(relativePath), model.Id + "_Logo"); } if (model.Background != null) { Functions.SaveFile(model.Background, relativePath, Server.MapPath(relativePath), model.Id + "_Background"); } ListService.UpdateImages(model); return(RedirectToAction("View")); }
public ActionResult Edit(ListItemLocal itemDetail) { var relativePath = ConfigurationManager.AppSettings["saveImagesIn"]; if (itemDetail.Logo != null) { Functions.SaveFile(itemDetail.Logo, relativePath, Server.MapPath(relativePath), itemDetail.Id + "_Logo"); } if (itemDetail.Background != null) { Functions.SaveFile(itemDetail.Background, relativePath, Server.MapPath(relativePath), itemDetail.Id + "_Background"); } itemDetail.Id = ListService.Edit(itemDetail); var cats = ListService.GetCategories(true); ViewBag.Type = new SelectList(cats, "CatId", "Name", itemDetail.Id); return(RedirectToAction("view")); }
public ActionResult Index() { var obj = new ListItemLocal { Type = 3, Name = "Type 3 - 2", Description = "No Description Given", Location = "32.09249466_74.08739947", Phone = "055-89335696", Rating = "4.1", Address = "Noshehra Road Grw", LogoImage = "https://via.placeholder.com/200x100", BgImage = "https://via.placeholder.com/200x100", Status = true }; // ListService.AddNewRestaurent(obj); return(View()); }
// GET: MenuItems/Edit/5 public async Task <ActionResult> Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ListItem item = await db.ListItems.FindAsync(id); ListItemLocal itemDetail = item.MapListItem(); if (itemDetail == null) { return(HttpNotFound()); } var cats = ListService.GetCategories(true); ViewBag.Type = new SelectList(cats, "CatId", "Name", itemDetail.Type); return(View(itemDetail)); }
public static bool UpdateImages(ListItemLocal source) { using (var dbContext = new DeliversEntities()) { var item = dbContext.ListItems.First(x => x.Id == source.Id); //if (string.IsNullOrEmpty(source.BgImage)) //{ item.BgImage = "image added"; //} //if (string.IsNullOrEmpty(source.LogoImage)) //{ item.LogoImage = "logo added"; //} item.LastEdit = CommonService.GetSystemTime(); dbContext.SaveChanges(); } return(true); }
// GET: MenuItems/Details/5 public async Task <ActionResult> Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ListItemLocal listItemLocal = await ListService.DetailsAsync(id.Value); if (listItemLocal == null) { return(HttpNotFound()); } var restType = ListService.GetRestaurantType(listItemLocal.Type); if (restType != null) { listItemLocal.TypeName = restType.Name; } return(View(listItemLocal)); }
public static long Edit(ListItemLocal source) { DbGeography loc = null; List <string> latlng = new List <string>(); if (!string.IsNullOrEmpty(source.Cords) && source.Cords != "") { latlng = source.Cords.Split('_').ToList(); if (latlng.Count == 2) { loc = CommonService.ConvertLatLonToDbGeography(latlng[1], latlng[0]); // lat _ lng } } using (var dbContext = new DeliversEntities()) { var obj = dbContext.ListItems.FirstOrDefault(x => x.Id == source.Id); obj.Address = source.Address; obj.Closes = source.Closes; obj.Cords = loc; obj.Description = source.Description; obj.LastEdit = CommonService.GetSystemTime(); obj.Location = loc; obj.Name = source.Name; obj.Phone = source.Phone; obj.Opens = source.Opens; obj.Status = source.Status; obj.Type = source.Type; obj.MinOrder = source.MinOrder; if (!string.IsNullOrWhiteSpace(source.BgImage)) { obj.BgImage = "bg_edit"; } if (!string.IsNullOrWhiteSpace(source.LogoImage)) { obj.LogoImage = "logo_edit"; } dbContext.SaveChanges(); } return(source.Id); }
public static long Create(ListItemLocal source) { DbGeography loc = null; List <string> latlng = new List <string>(); if (!string.IsNullOrEmpty(source.Cords) && source.Cords != "") { latlng = source.Cords.Split('_').ToList(); if (latlng.Count == 2) { loc = CommonService.ConvertLatLonToDbGeography(latlng[1], latlng[0]); // lat _ lng } } var obj = new ListItem { Address = source.Address, BgImage = "https://via.placeholder.com/1350x450", Closes = source.Closes, Cords = loc, CreationDate = CommonService.GetSystemTime(), Description = source.Description, LastEdit = CommonService.GetSystemTime(), Location = loc, Name = source.Name, Phone = source.Phone, Opens = source.Opens, Status = source.Status, Type = source.Type, Rating = "0.00", MinOrder = source.MinOrder, LogoImage = "https://via.placeholder.com/120x120" }; using (var dbContext = new DeliversEntities()) { dbContext.ListItems.Add(obj); dbContext.SaveChanges(); } return(obj.Id); }