public ActionResult SaveOrder(string kafileAd, string kafileUlke, int kafileKisiSayisi, int turID, Turist[] turist) { int sess = Convert.ToInt32(Session["userID"]); string result = "Ekleme işlemi Başarısız"; if (ModelState.IsValid) { Kafile model = new Kafile(); model.kafileAd = kafileAd; model.kafileKisiSayisi = kafileKisiSayisi; model.kafileUlke = kafileUlke; model.turID = turID; model.isDeleted = false; db.Kafiles.Add(model); foreach (var item in turist) { Turist t = new Turist(); t.turistAd = item.turistAd; t.turistTel = item.turistTel; t.turistYas = item.turistYas; t.turistCinsiyet = item.turistCinsiyet; t.turistPasaportNo = item.turistPasaportNo; t.turistTC = item.turistTC; t.kafileID = model.kafileID; db.Turists.Add(t); } db.SaveChanges(); result = "Tebrikler Başarıyla Tamamlandı"; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(Ekstra eks, HttpPostedFileBase ekstraFoto) { int sess = Convert.ToInt32(Session["userID"]); if (ModelState.IsValid) { if (ekstraFoto != null) { WebImage img = new WebImage(ekstraFoto.InputStream); FileInfo fotoinfo = new FileInfo(ekstraFoto.FileName); string newfoto = Guid.NewGuid().ToString() + fotoinfo.Extension; img.Resize(150, 150); img.Save("~/Uploads/EkstraPhoto/" + newfoto); eks.ekstraFoto = "/Uploads/EkstraPhoto/" + newfoto; db.Ekstras.Add(eks); eks.userID = sess; db.SaveChanges(); return(RedirectToAction("Index", "Ekstra")); } else { db.Ekstras.Add(eks); eks.userID = sess; db.SaveChanges(); return(RedirectToAction("Index", "Ekstra")); } } return(View(eks)); }
public ActionResult Create(Muze muze, HttpPostedFileBase muzeFoto) { int sess = Convert.ToInt32(Session["userID"]); if (ModelState.IsValid) { if (muzeFoto != null) { WebImage img = new WebImage(muzeFoto.InputStream); FileInfo fotoinfo = new FileInfo(muzeFoto.FileName); string newfoto = Guid.NewGuid().ToString() + fotoinfo.Extension; img.Resize(150, 150); img.Save("~/Uploads/MuzePhoto/" + newfoto); muze.muzeFoto = "/Uploads/MuzePhoto/" + newfoto; muze.isDeleted = false; muze.userID = sess; db.Muzes.Add(muze); db.SaveChanges(); return(RedirectToAction("Index", "Muze")); } else { muze.isDeleted = false; muze.userID = sess; db.Muzes.Add(muze); db.SaveChanges(); return(RedirectToAction("Index", "Muze")); } } return(View(muze)); }
public ActionResult Create(Otel otel, HttpPostedFileBase otelResim) { int sess = Convert.ToInt32(Session["userID"]); if (ModelState.IsValid) { if (otelResim != null) { WebImage img = new WebImage(otelResim.InputStream); FileInfo fotoinfo = new FileInfo(otelResim.FileName); string newfoto = Guid.NewGuid().ToString() + fotoinfo.Extension; img.Resize(150, 150); img.Save("~/Uploads/OtelPhoto/" + newfoto); otel.otelResim = "/Uploads/OtelPhoto/" + newfoto; otel.userID = sess; otel.isDeleted = false; db.Otels.Add(otel); db.SaveChanges(); return(RedirectToAction("Index", "Otel")); } else { otel.userID = sess; otel.isDeleted = false; db.Otels.Add(otel); db.SaveChanges(); return(RedirectToAction("Index", "Otel")); } } return(View(otel)); }
public ActionResult Create(Restorant restorant, HttpPostedFileBase restorantFoto) { int sess = Convert.ToInt32(Session["userID"]); if (ModelState.IsValid) { if (restorantFoto != null) { WebImage img = new WebImage(restorantFoto.InputStream); FileInfo fotoinfo = new FileInfo(restorantFoto.FileName); string newfoto = Guid.NewGuid().ToString() + fotoinfo.Extension; img.Resize(150, 150); img.Save("~/Uploads/RestorantPhoto/" + newfoto); restorant.restorantFoto = "/Uploads/RestorantPhoto/" + newfoto; restorant.userID = sess; restorant.isDeleted = false; db.Restorants.Add(restorant); db.SaveChanges(); return(RedirectToAction("Index", "Restorant")); } else { restorant.userID = sess; restorant.isDeleted = false; db.Restorants.Add(restorant); db.SaveChanges(); return(RedirectToAction("Index", "Restorant")); } } return(View(restorant)); }
/* public JsonResult SaveData(User user) * { * db.Users.Add(user); * user.isDeleted = false; * user.userTipID = 2; * user.active = true; * db.SaveChanges(); * return Json("Registration Successfull", JsonRequestBehavior.AllowGet); * } */ public JsonResult SaveData(User user) { db.Users.Add(user); user.isDeleted = false; user.userTipID = 2; user.active = true; db.SaveChanges(); return(Json("Registration Successfull", JsonRequestBehavior.AllowGet)); }
public JsonResult SaveData(AltFirma frm) { int sess = Convert.ToInt32(Session["userID"]); db.AltFirmas.Add(frm); frm.userID = sess; frm.isDeleted = false; db.SaveChanges(); return(Json("Registration Successfull", JsonRequestBehavior.AllowGet)); }
public JsonResult SaveData(Arac arac) { int sess = Convert.ToInt32(Session["userID"]); db.Aracs.Add(arac); arac.isDeleted = false; arac.userID = sess; db.SaveChanges(); return(Json("Registration Successfull", JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteTravelPromotion(int id) { using (var db = new TourEntities()) { var tpromotion = db.TravelPromotion.Where(e => e.TravelPromotionId == id).FirstOrDefault(); if (tpromotion == null) { return(new HttpNotFoundResult("Travel Promotion not found")); } else { FileInfo path = new FileInfo(Server.MapPath("~/Image/TravelPromotionImage/" + tpromotion.PhotoPath)); path.Delete(); db.TravelPromotion.Remove(tpromotion); db.SaveChanges(); } List <TravelPromotionViewModel> travelPromotion = (from data in db.TravelPromotion select new TravelPromotionViewModel() { TravelPromotionId = data.TravelPromotionId, Description = data.Description, PhotoPath = data.PhotoPath, CreatedAt = data.CreatedAt, UpdatedAt = data.UpdatedAt }).ToList(); return(View("TravelPromotion", travelPromotion)); } }
public JsonResult AddMerchantPromotion(AddMerchantPromotionViewModel model) { using (var db = new TourEntities()) { if (ModelState.IsValid) { var formsAuthentication = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName] != null ? FormsAuthentication.Decrypt( HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value) : null; var newMerchantPromotion = new MerchantPromotion() { MechantId = model.MerchantId, MerchantPromotionDetail = model.MerchantPromotionDetail, CreatedBy = MetadataServices.GetCurrentUser().Username, CreatedAt = MetadataServices.GetCurrentDate(), UpdatedBy = MetadataServices.GetCurrentUser().Username, UpdatedAt = MetadataServices.GetCurrentDate() }; db.MerchantPromotion.Add(newMerchantPromotion); db.SaveChanges(); } return(Json(new { }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddProductRedeem(AddProductRedeemViewModel model) { using (var db = new TourEntities()) { if (ModelState.IsValid) { var formsAuthentication = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName] != null ? FormsAuthentication.Decrypt( HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value) : null; string imageName = System.IO.Path.GetFileName(model.ImagePath.FileName); imageName = MetadataServices.GetDateTimeWithoutSlash() + "-" + imageName; string physicalPath = Server.MapPath("~/Image/Product/" + imageName); model.ImagePath.SaveAs(physicalPath); var newProductRedeemViewModel = new ProductRedeem() { ProductRedeemName = model.ProductRedeemName, RedeemPoint = model.RedeemPoint, Stock = model.Stock, ImagePath = imageName, CreatedBy = MetadataServices.GetCurrentUser().Username, CreatedAt = MetadataServices.GetCurrentDate(), UpdatedBy = MetadataServices.GetCurrentUser().Username, UpdatedAt = MetadataServices.GetCurrentDate() }; db.ProductRedeem.Add(newProductRedeemViewModel); db.SaveChanges(); } return(Json(new { }, JsonRequestBehavior.AllowGet)); } }
public ActionResult DeleteGoodNews(int id) { using (var db = new TourEntities()) { if (ModelState.IsValid) { var news = db.GoodNews.Find(id); if (news == null) { return(new HttpNotFoundResult("News not found.")); } FileInfo path = new FileInfo(Server.MapPath("~/Image/GoodNews/" + news.PhotoPath)); path.Delete(); db.GoodNews.Remove(news); db.SaveChanges(); return(RedirectToAction("GoodNews", "GoodNews")); } else { return(View()); } } }
public JsonResult AddGoodNews(AddGoodNewsViewModel model) { using (var db = new TourEntities()) { if (ModelState.IsValid) { var formsAuthentication = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName] != null ? FormsAuthentication.Decrypt( HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value) : null; string imageName = System.IO.Path.GetFileName(model.PhotoPath.FileName); imageName = MetadataServices.GetDateTimeWithoutSlash() + "-" + imageName; string physicalPath = Server.MapPath("~/Image/GoodNews/" + imageName); model.PhotoPath.SaveAs(physicalPath); var goodNews = new GoodNews() { GoodNewsTitle = model.GoodNewsTitle, PhotoPath = imageName, Description = model.Description == null ? "" : model.Description, CreatedBy = MetadataServices.GetCurrentUser().Username, CreatedAt = MetadataServices.GetCurrentDate(), UpdatedBy = MetadataServices.GetCurrentUser().Username, UpdatedAt = MetadataServices.GetCurrentDate(), }; db.GoodNews.Add(goodNews); db.SaveChanges(); } return(Json(new { }, JsonRequestBehavior.AllowGet)); } }
public ActionResult DeleteProductRedeem(int id) { using (var db = new TourEntities()) { if (ModelState.IsValid) { var productRedeem = db.ProductRedeem.Find(id); if (productRedeem == null) { return(new HttpNotFoundResult("Product Redeem not found.")); } FileInfo path = new FileInfo(Server.MapPath("~/Image/Product/" + productRedeem.ImagePath)); path.Delete(); db.ProductRedeem.Remove(productRedeem); db.SaveChanges(); return(RedirectToAction("ProductRedeem", "Product")); } else { return(View()); } } }
public ActionResult DeleteMerchant(int id) { using (var db = new TourEntities()) { if (ModelState.IsValid) { var merchant = db.Merchant.Find(id); if (merchant == null) { return(new HttpNotFoundResult("Merchant not found.")); } FileInfo path = new FileInfo(Server.MapPath("~/Image/Merchant/" + merchant.MerchantLogoPath)); path.Delete(); db.Merchant.Remove(merchant); db.SaveChanges(); return(RedirectToAction("Merchant", "Merchant")); } else { return(View()); } } }
public JsonResult EditMerchantPromotion(AddMerchantPromotionViewModel model) { try { using (var db = new TourEntities()) { var formsAuthentication = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName] != null ? FormsAuthentication.Decrypt( HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value) : null; if (ModelState.IsValid) { var merchantPromo = db.MerchantPromotion.Find(model.MerchantPromotionId); merchantPromo.MechantId = model.MerchantId; merchantPromo.MerchantPromotionDetail = model.MerchantPromotionDetail; merchantPromo.UpdatedBy = MetadataServices.GetCurrentUser().Username; merchantPromo.UpdatedAt = MetadataServices.GetCurrentDate(); db.SaveChanges(); } return(Json(new { }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { throw ex; } }
public ActionResult DeletePackage(int id) { using (var db = new TourEntities()) { if (ModelState.IsValid) { var package = db.Package.Find(id); if (package == null) { return(new HttpNotFoundResult("Package not found.")); } FileInfo path = new FileInfo(Server.MapPath("~/Image/Package/" + package.PhotoPath)); path.Delete(); package.IsDeleted = true; db.SaveChanges(); return(RedirectToAction("Package", "Package")); } else { return(View()); } } }
public ActionResult KafileEdit(int?kafileID, Kafile x) { int sess = Convert.ToInt32(Session["userID"]); if (ModelState.IsValid) { var kafileler = db.Kafiles.Where(m => m.kafileID == kafileID).SingleOrDefault(); kafileler.kafileAd = x.kafileAd; kafileler.kafileKisiSayisi = x.kafileKisiSayisi; kafileler.kafileUlke = x.kafileUlke; db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }
public JsonResult RedeemCoupon(RedeemCouponViewModel model) { using (var db = new TourEntities()) { var couponTransaction = db.RedeemCoupon.Where(x => x.CouponCode == model.CouponCode).FirstOrDefault(); if (couponTransaction != null) { ModelState.AddModelError("CouponCode", "Coupon Code had been redeem before."); } if (ModelState.IsValid) { string imageName = ""; RedeemCoupon newCoupon = new RedeemCoupon(); if (model.Image != null) { imageName = System.IO.Path.GetFileName(model.Image.FileName); imageName = MetadataServices.GetDateTimeWithoutSlash() + "-" + imageName; string physicalPath = Server.MapPath("~/Image/RedeemCoupon/" + imageName); model.Image.SaveAs(physicalPath); } var currentUser = MetadataServices.GetCurrentUser(); var customer = db.Customer.Where(x => x.UserId == currentUser.UserId).FirstOrDefault(); newCoupon.CouponCode = model.CouponCode; newCoupon.TVRAmount = model.Amount; newCoupon.ImageProof = imageName; newCoupon.CustomerId = customer.CustomerId; newCoupon.CreatedBy = currentUser.Username; newCoupon.CreatedAt = DateTime.Now; newCoupon.UpdatedAt = DateTime.Now; newCoupon.UpdatedBy = currentUser.Username; newCoupon.TransactionStatus = (int)EnjoyOurTour.Helpers.TransactionStatus.Pending; db.RedeemCoupon.Add(newCoupon); db.SaveChanges(); return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } else { List <string> errors = new List <string>(); foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { errors.Add(string.IsNullOrEmpty(error.ErrorMessage) ? error.Exception.ToString() : error.ErrorMessage); } } return(Json(new { success = false, errors = errors }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult Create(Rehber rehber, HttpPostedFileBase rehberPhoto, string diller) { int sess = Convert.ToInt32(Session["userID"]); if (ModelState.IsValid) { if (rehberPhoto != null && !string.IsNullOrEmpty(diller)) { WebImage img = new WebImage(rehberPhoto.InputStream); FileInfo fotoinfo = new FileInfo(rehberPhoto.FileName); string newfoto = Guid.NewGuid().ToString() + fotoinfo.Extension; img.Resize(150, 150); img.Save("~/Uploads/RehberPhoto/" + newfoto); rehber.rehberPhoto = "/Uploads/RehberPhoto/" + newfoto; string[] dilDizi = diller.Split(','); foreach (var i in dilDizi) { var yeniDil = new Dil { dilAd = i }; db.Dils.Add(yeniDil); rehber.Dils.Add(yeniDil); } rehber.isDeleted = false; rehber.userID = sess; db.Rehbers.Add(rehber); db.SaveChanges(); return(RedirectToAction("Index", "Rehber")); } else { ModelState.AddModelError("Fotoğraf", "Fotoğraf Seçiniz"); } } return(View(rehber)); }
public JsonResult EditTravelPromotion(TravelPromotionViewModel model) { try { using (var db = new TourEntities()) { if (ModelState.IsValid) { var formsAuthentication = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName] != null ? FormsAuthentication.Decrypt( HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value) : null; TravelPromotion travelPromotion = db.TravelPromotion.Where(e => e.TravelPromotionId == model.TravelPromotionId).FirstOrDefault(); if (model.Description == null) { travelPromotion.Description = ""; } else { travelPromotion.Description = model.Description; } if (model.Image != null) { FileInfo path = new FileInfo(Server.MapPath("~/Image/TravelPromotionImage/" + travelPromotion.PhotoPath)); path.Delete(); string imageName = System.IO.Path.GetFileName(model.Image.FileName); imageName = MetadataServices.GetDateTimeWithoutSlash() + "-" + imageName; string physicalPath = Server.MapPath("~/Image/TravelPromotionImage/" + imageName); model.Image.SaveAs(physicalPath); travelPromotion.PhotoPath = imageName; } travelPromotion.TravelPromotionTitle = model.TravelPromotionTitle; travelPromotion.UpdatedAt = MetadataServices.GetCurrentDate(); travelPromotion.UpdatedBy = MetadataServices.GetCurrentUser().Username; db.SaveChanges(); } return(Json(new { }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { throw ex; } }
public JsonResult EditMerchant(AddMerchantViewModel model) { try { using (var db = new TourEntities()) { var formsAuthentication = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName] != null ? FormsAuthentication.Decrypt( HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value) : null; if (ModelState.IsValid) { var merchant = db.Merchant.Find(model.MerchantId); if (model.MerchantLogoPath != null) { FileInfo path = new FileInfo(Server.MapPath("~/Image/Merchant/" + merchant.MerchantLogoPath)); path.Delete(); string imageName = System.IO.Path.GetFileName(model.MerchantLogoPath.FileName); imageName = MetadataServices.GetDateTimeWithoutSlash() + "-" + imageName; string physicalPath = Server.MapPath("~/Image/Merchant/" + imageName); model.MerchantLogoPath.SaveAs(physicalPath); merchant.MerchantLogoPath = imageName; } merchant.MerchantId = model.MerchantId; merchant.MerchantName = model.MerchantName; merchant.MerchantRegisterCode = model.MerchantRegisterCode; merchant.MerchantPhoneNumber = model.MerchantPhoneNumber; merchant.MerchantAddress = model.MerchantAddress; merchant.MerchantCategoryId = model.GetMerchantCategoryId; merchant.MerchantJoinDate = model.MerchantJoinDate; merchant.UpdatedBy = MetadataServices.GetCurrentUser().Username; merchant.UpdatedAt = MetadataServices.GetCurrentDate(); db.SaveChanges(); } return(Json(new { }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { throw ex; } }
public JsonResult UpdateCustomerProfile(UpdateCustomerProfileViewModel model) { using (var db = new TourEntities()) { var userWithNRIC = db.Customer.Where(x => x.NRIC == model.NRIC && x.CustomerId != model.CustomerId).FirstOrDefault(); if (userWithNRIC != null) { ModelState.AddModelError("NRIC", "NRIC Duplication"); } if (ModelState.IsValid) { var customer = db.Customer.Where(x => x.CustomerId == model.CustomerId).FirstOrDefault(); customer.CustomerName = model.CustomerName; customer.NRIC = model.NRIC; customer.PhoneNumber = model.PhoneNumber; customer.Address = model.Address; customer.BankAccountNumber = model.BankAccountNumber; customer.BankName = model.BankName; customer.DateOfBirth = model.DateOfBirth; var user = db.User.Where(x => x.UserId == customer.UserId).FirstOrDefault(); user.EmailAddress = model.EmailAddress; db.SaveChanges(); return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } else { List <string> errors = new List <string>(); foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { errors.Add(string.IsNullOrEmpty(error.ErrorMessage) ? error.Exception.ToString() : error.ErrorMessage); } } return(Json(new { success = false, issue = model, errors = errors }, JsonRequestBehavior.AllowGet)); } } }
public JsonResult EditProductRedeem(AddProductRedeemViewModel model) { try { using (var db = new TourEntities()) { var formsAuthentication = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName] != null ? FormsAuthentication.Decrypt( HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value) : null; if (ModelState.IsValid) { var productRedeem = db.ProductRedeem.Find(model.ProductRedeemId); if (model.ImagePath != null) { FileInfo path = new FileInfo(Server.MapPath("~/Image/Product/" + model.ImagePath)); path.Delete(); string imageName = System.IO.Path.GetFileName(model.ImagePath.FileName); imageName = MetadataServices.GetDateTimeWithoutSlash() + "-" + imageName; string physicalPath = Server.MapPath("~/Image/Product/" + imageName); model.ImagePath.SaveAs(physicalPath); productRedeem.ImagePath = imageName; } productRedeem.ProductRedeemName = model.ProductRedeemName; productRedeem.Stock = model.Stock; productRedeem.RedeemPoint = model.RedeemPoint; productRedeem.UpdatedBy = MetadataServices.GetCurrentUser().Username; productRedeem.UpdatedAt = MetadataServices.GetCurrentDate(); db.SaveChanges(); } return(Json(new { }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { throw ex; } }
public JsonResult EditGoodNews(AddGoodNewsViewModel model) { try { using (var db = new TourEntities()) { var formsAuthentication = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName] != null ? FormsAuthentication.Decrypt( HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value) : null; if (ModelState.IsValid) { var news = db.GoodNews.Find(model.GoodNewsId); if (model.PhotoPath != null) { FileInfo path = new FileInfo(Server.MapPath("~/Image/GoodNews/" + news.PhotoPath)); path.Delete(); string imageName = System.IO.Path.GetFileName(model.PhotoPath.FileName); imageName = MetadataServices.GetDateTimeWithoutSlash() + "-" + imageName; string physicalPath = Server.MapPath("~/Image/GoodNews/" + imageName); model.PhotoPath.SaveAs(physicalPath); news.PhotoPath = imageName; } news.GoodNewsTitle = model.GoodNewsTitle; news.Description = model.Description; news.UpdatedBy = MetadataServices.GetCurrentUser().Username; news.UpdatedAt = MetadataServices.GetCurrentDate(); db.SaveChanges(); } return(Json(new { }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { throw ex; } }
public JsonResult AddPackage(AddPackageViewModel model) { using (var db = new TourEntities()) { if (ModelState.IsValid) { var formsAuthentication = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName] != null ? FormsAuthentication.Decrypt( HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value) : null; string imageName = System.IO.Path.GetFileName(model.PhotoPath.FileName); imageName = MetadataServices.GetDateTimeWithoutSlash() + "-" + imageName; string physicalPath = Server.MapPath("~/Image/Package/" + imageName); model.PhotoPath.SaveAs(physicalPath); string fileName = System.IO.Path.GetFileName(model.ItineraryFile.FileName); fileName = MetadataServices.GetDateTimeWithoutSlash() + "-" + fileName; string filePath = Server.MapPath("~/Files/" + fileName); model.ItineraryFile.SaveAs(filePath); var newPackage = new Package() { PackageName = model.PackageName, PhotoPath = imageName, FilePath = fileName, Description = model.Description == null ? "" : model.Description, IteneraryDetail = model.IteneraryDetail == null ? "" : model.IteneraryDetail, TVR = model.TVR, Amount = model.Amount, CreatedBy = MetadataServices.GetCurrentUser().Username, CreatedAt = MetadataServices.GetCurrentDate(), UpdatedBy = MetadataServices.GetCurrentUser().Username, UpdatedAt = MetadataServices.GetCurrentDate(), IsDeleted = false }; db.Package.Add(newPackage); db.SaveChanges(); } return(Json(new { }, JsonRequestBehavior.AllowGet)); } }
public ActionResult TeklifOnayla(List <Kotasyon> model) { foreach (var item in model) { var kotasyonDurum = db.Kotasyons.FirstOrDefault(q => q.kotasyonID == item.kotasyonID); if (kotasyonDurum != null) { if (kotasyonDurum.onaylanmis == false) { kotasyonDurum.onaylanmis = true; } else { kotasyonDurum.onaylanmis = false; } db.SaveChanges(); } } return(RedirectToAction("Index", "Home")); }
public ActionResult UpdateAgentProfile(EditAgentProfileViewModel model) { using (var db = new TourEntities()) { if (ModelState.IsValid) { var agent = db.Agent.Find(model.AgentId); var user = db.User.Find(MetadataServices.GetCurrentUser().UserId); if (agent == null || user == null) { return(new HttpNotFoundResult("Agent not found.")); } bool chkIC = db.Agent.Where(x => x.NRIC == model.NRIC).Any(); if (!chkIC) { agent.AgentCode = Convert.ToInt32(model.NRIC.Substring(model.NRIC.Length - 6)); } user.EmailAddress = model.EmailAddress; agent.AgentName = model.AgentName; agent.BankName = model.BankName; agent.BankAccountNumber = model.BankAccountNumber; agent.Address = model.Address; agent.DOB = model.DOB; agent.NRIC = model.NRIC; agent.PhoneNumber = model.PhoneNumber; agent.UserId = user.UserId; agent.UpdatedAt = MetadataServices.GetCurrentDate(); agent.UpdatedBy = MetadataServices.GetCurrentUser().Username; db.SaveChanges(); return(RedirectToAction("UpdateAgentProfile", "Agent")); } return(View(model)); } }
public JsonResult AddMerchant(AddMerchantViewModel model) { using (var db = new TourEntities()) { if (ModelState.IsValid) { var formsAuthentication = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName] != null ? FormsAuthentication.Decrypt( HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value) : null; string imageName = System.IO.Path.GetFileName(model.MerchantLogoPath.FileName); imageName = MetadataServices.GetDateTimeWithoutSlash() + "-" + imageName; string physicalPath = Server.MapPath("~/Image/Merchant/" + imageName); model.MerchantLogoPath.SaveAs(physicalPath); var newMerchant = new Merchant() { MerchantId = model.MerchantId, MerchantName = model.MerchantName, MerchantRegisterCode = model.MerchantRegisterCode, MerchantPhoneNumber = model.MerchantPhoneNumber, MerchantAddress = model.MerchantAddress, MerchantCategoryId = model.GetMerchantCategoryId, MerchantJoinDate = model.MerchantJoinDate, MerchantLogoPath = imageName, CreatedBy = MetadataServices.GetCurrentUser().Username, CreatedAt = MetadataServices.GetCurrentDate(), UpdatedBy = MetadataServices.GetCurrentUser().Username, UpdatedAt = MetadataServices.GetCurrentDate() }; db.Merchant.Add(newMerchant); db.SaveChanges(); } return(Json(new { }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddTravelPromotion(TravelPromotionViewModel model) { using (var db = new TourEntities()) { if (ModelState.IsValid) { var formsAuthentication = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName] != null ? FormsAuthentication.Decrypt( HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value) : null; TravelPromotion travelPromotion = new TravelPromotion(); if (model.Description == null) { travelPromotion.Description = ""; } else { travelPromotion.Description = model.Description; } string imageName = System.IO.Path.GetFileName(model.Image.FileName); imageName = MetadataServices.GetDateTimeWithoutSlash() + "-" + imageName; string physicalPath = Server.MapPath("~/Image/TravelPromotionImage/" + imageName); model.Image.SaveAs(physicalPath); travelPromotion.TravelPromotionTitle = model.TravelPromotionTitle; travelPromotion.PhotoPath = imageName; travelPromotion.CreatedAt = MetadataServices.GetCurrentDate(); travelPromotion.CreatedBy = MetadataServices.GetCurrentUser().Username; travelPromotion.UpdatedAt = MetadataServices.GetCurrentDate(); travelPromotion.UpdatedBy = MetadataServices.GetCurrentUser().Username; db.TravelPromotion.Add(travelPromotion); db.SaveChanges(); } return(Json(new { }, JsonRequestBehavior.AllowGet)); } }