public ActionResult DeleteConfirmed(Guid id) { DailyPromoterProductSale dailyPromoterProductSale = db.DailyPromoterProductSales.Find(id); dailyPromoterProductSale.IsDeleted = true; dailyPromoterProductSale.DeletionDate = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(DailyPromoterProductSale dailyPromoterProductSale) { if (ModelState.IsValid) { dailyPromoterProductSale.IsDeleted = false; db.Entry(dailyPromoterProductSale).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DailyPromoterPlanId = new SelectList(db.DailyPromoterPlans, "Id", "StartLat", dailyPromoterProductSale.DailyPromoterPlanId); ViewBag.ProjectProductId = new SelectList(db.ProjectProducts, "Id", "ProductTitle", dailyPromoterProductSale.ProjectProductId); return(View(dailyPromoterProductSale)); }
public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DailyPromoterProductSale dailyPromoterProductSale = db.DailyPromoterProductSales.Find(id); if (dailyPromoterProductSale == null) { return(HttpNotFound()); } return(View(dailyPromoterProductSale)); }
public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DailyPromoterProductSale dailyPromoterProductSale = db.DailyPromoterProductSales.Find(id); if (dailyPromoterProductSale == null) { return(HttpNotFound()); } ViewBag.DailyPromoterPlanId = new SelectList(db.DailyPromoterPlans, "Id", "StartLat", dailyPromoterProductSale.DailyPromoterPlanId); ViewBag.ProjectProductId = new SelectList(db.ProjectProducts, "Id", "ProductTitle", dailyPromoterProductSale.ProjectProductId); return(View(dailyPromoterProductSale)); }
public ActionResult Create(DailyPromoterProductSale dailyPromoterProductSale) { if (ModelState.IsValid) { dailyPromoterProductSale.IsDeleted = false; dailyPromoterProductSale.CreationDate = DateTime.Now; dailyPromoterProductSale.Id = Guid.NewGuid(); db.DailyPromoterProductSales.Add(dailyPromoterProductSale); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DailyPromoterPlanId = new SelectList(db.DailyPromoterPlans, "Id", "StartLat", dailyPromoterProductSale.DailyPromoterPlanId); ViewBag.ProjectProductId = new SelectList(db.ProjectProducts, "Id", "ProductTitle", dailyPromoterProductSale.ProjectProductId); return(View(dailyPromoterProductSale)); }
public ActionResult SubmitSale(string productId, string dailyPromoterPlanId, string qty, string desc) { try { Guid id = new Guid(dailyPromoterPlanId); Guid projectProductId = new Guid(productId); DailyPromoterProductSale dailyPromoterProductSale = db.DailyPromoterProductSales.FirstOrDefault(c => c.DailyPromoterPlanId == id && c.ProjectProductId == projectProductId && c.IsDeleted == false); if (dailyPromoterProductSale == null) { DailyPromoterProductSale oDailyPromoterProductSale = new DailyPromoterProductSale() { Id = Guid.NewGuid(), ProjectProductId = projectProductId, DailyPromoterPlanId = id, Count = Convert.ToInt32(qty), PromoterDescription = desc, IsActive = true, IsDeleted = false, CreationDate = DateTime.Now }; db.DailyPromoterProductSales.Add(oDailyPromoterProductSale); } else { dailyPromoterProductSale.Count = Convert.ToInt32(qty); dailyPromoterProductSale.PromoterDescription = desc; dailyPromoterProductSale.LastModifiedDate = DateTime.Now; } db.SaveChanges(); return(Json("true", JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json("false", JsonRequestBehavior.AllowGet)); } }
public List <ProjectProductItem> GetProjectProduct(Guid projectId, Guid dailyPromoterPlanId) { List <ProjectProductItem> result = new List <ProjectProductItem>(); var projectProducts = db.ProjectProducts .Where(c => c.ProjectId == projectId && c.IsDeleted == false && c.IsActive).Select(c => new { c.Id, c.ProductTitle, c.ImageUrl, c.ProductDescription }); foreach (var projectProduct in projectProducts) { int count = 0; string promoterDescription = null; DailyPromoterProductSale dailyPromoterProductSale = db.DailyPromoterProductSales.FirstOrDefault(c => c.DailyPromoterPlanId == dailyPromoterPlanId && c.ProjectProductId == projectProduct.Id && c.IsDeleted == false); if (dailyPromoterProductSale != null) { count = dailyPromoterProductSale.Count; promoterDescription = dailyPromoterProductSale.PromoterDescription; } result.Add(new ProjectProductItem() { ProductId = projectProduct.Id, ImageUrl = projectProduct.ImageUrl, ProductDescription = projectProduct.ProductDescription, ProductTitle = projectProduct.ProductTitle, Count = count, PromoterDesc = promoterDescription }); } return(result); }