public ActionResult InsertQuotation() { if (Session["UserID"] == null && Session["UserName"] == null) { return(RedirectToAction("Login", "Login")); } try { if (ModelState.IsValid) { int AAVECID = Convert.ToInt32(Request.Form["AAVECID"]); tblAlbumAndVideoEditingCharge AAVEC = db.tblAlbumAndVideoEditingCharges.SingleOrDefault(A => A.AlbumAndVideoEditingChargesID == AAVECID); tblQuotation quotation = new tblQuotation(); quotation.AlbumAndVideoEditingChargesID = AAVECID; quotation.EventDate = Convert.ToDateTime(Request.Form["EventDate"]); quotation.FunctionName = Request.Form["FunctionName"]; quotation.CandidCinematographers = string.IsNullOrEmpty(Request.Form["CandidCinemato"])? 0 : Convert.ToInt32(Request.Form["CandidCinemato"]); quotation.RegularCinematographers = string.IsNullOrEmpty(Request.Form["RegularCinemato"]) ? 0 : Convert.ToInt32(Request.Form["RegularCinemato"]); quotation.CandidPhotographer = string.IsNullOrEmpty(Request.Form["CandidPhoto"]) ? 0 : Convert.ToInt32(Request.Form["CandidPhoto"]); quotation.RegularPhotographer = string.IsNullOrEmpty(Request.Form["RegularPhoto"]) ? 0 : Convert.ToInt32(Request.Form["RegularPhoto"]); quotation.DSLR = string.IsNullOrEmpty(Request.Form["DSLR"]) ? 0 : Convert.ToInt32(Request.Form["DSLR"]); quotation.NumberOfDrones = string.IsNullOrEmpty(Request.Form["Drones"]) ? 0 : Convert.ToInt32(Request.Form["Drones"]); quotation.NumberOfLedScreens = string.IsNullOrEmpty(Request.Form["LEDScreen"]) ? 0 : Convert.ToInt32(Request.Form["LEDScreen"]); quotation.Others = string.IsNullOrEmpty(Request.Form["Other"]) ? string.Empty : Request.Form["Other"]; quotation.TotalAmount = Convert.ToDecimal(Request.Form["TotalAmount"]); if (AAVEC.IsDisscount == true) { AAVEC.OriginalAmount += Convert.ToDecimal(quotation.TotalAmount); decimal DiscountedAmount = (Convert.ToDecimal(AAVEC.OriginalAmount) * Convert.ToDecimal(AAVEC.DiscountPercentage)) / 100; AAVEC.DiscountedAmount = DiscountedAmount; AAVEC.FinalAmount = AAVEC.OriginalAmount - DiscountedAmount; } else { AAVEC.OriginalAmount += Convert.ToDecimal(quotation.TotalAmount); AAVEC.FinalAmount = AAVEC.OriginalAmount; } quotation.CreatedDate = DateTime.Now; db.Entry(AAVEC).State = EntityState.Modified; db.SaveChanges(); db.tblQuotations.Add(quotation); db.SaveChanges(); return(Json(new { success = true, message = "Record inserted successfully" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Record is not inserted!" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false, message = "Error! " + ex.Message }, JsonRequestBehavior.AllowGet)); } }
public bool AddQuotation(QuotationEntities qe) { var config = new MapperConfiguration(cfg => cfg.CreateMap <QuotationEntities, tblQuotation>()); IMapper mapper = config.CreateMapper(); tblQuotation quot = mapper.Map <QuotationEntities, tblQuotation>(qe); return(quotationRepository.BookQuotation(quot)); //if (UserLogin.IsUserLogin()) //{ //} //else //{ // return false; //} }
public ActionResult DeleteQuotation(int id) { if (Session["UserID"] == null && Session["UserName"] == null) { return(RedirectToAction("Login", "Login")); } try { tblQuotation quotation = db.tblQuotations.Find(id); long AAVECID = Convert.ToInt64(quotation.AlbumAndVideoEditingChargesID); tblAlbumAndVideoEditingCharge AAVEC = db.tblAlbumAndVideoEditingCharges.SingleOrDefault(A => A.AlbumAndVideoEditingChargesID == AAVECID); if (AAVEC.IsDisscount == true) { AAVEC.OriginalAmount -= Convert.ToDecimal(quotation.TotalAmount); decimal DiscountedAmount = (Convert.ToDecimal(AAVEC.OriginalAmount) * Convert.ToDecimal(AAVEC.DiscountPercentage)) / 100; AAVEC.DiscountedAmount = DiscountedAmount; AAVEC.FinalAmount = AAVEC.OriginalAmount - DiscountedAmount; } else { AAVEC.OriginalAmount -= Convert.ToDecimal(quotation.TotalAmount); AAVEC.FinalAmount -= Convert.ToDecimal(quotation.TotalAmount); } db.Entry(AAVEC).State = EntityState.Modified; db.SaveChanges(); db.tblQuotations.Remove(quotation); db.SaveChanges(); return(Json(new { success = true, message = "Record deleted successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = "Error!" + ex.Message }, JsonRequestBehavior.AllowGet)); } }
public bool BookQuotation(tblQuotation objQuotation) { db.tblQuotations.Add(objQuotation); return(db.SaveChanges() > 0); }