예제 #1
0
        public ActionResult UpdateCustomerProfile(int userId)
        {
            using (var db = new TourEntities())
            {
                var customer = db.User_Customer_Adgent.Where(x => x.UserId == userId).FirstOrDefault();

                UpdateCustomerProfileViewModel customerViewModel = new UpdateCustomerProfileViewModel();

                customerViewModel.NRIC              = customer.NRIC;
                customerViewModel.CustomerId        = customer.CustomerId;
                customerViewModel.CustomerName      = customer.CustomerName;
                customerViewModel.EmailAddress      = customer.EmailAddress;
                customerViewModel.BankAccountNumber = customer.BankAccountNumber;
                customerViewModel.BankName          = customer.BankName;
                customerViewModel.PhoneNumber       = customer.PhoneNumber;
                customerViewModel.Address           = customer.Address;
                customerViewModel.DateOfBirth       = customer.DateOfBirth;
                customerViewModel.CustomerCode      = customer.CustomerCode;
                customerViewModel.RenewDate         = customer.RenewDate;
                customerViewModel.ExpiredDate       = customer.ExpiredDate;
                customerViewModel.AvailableAmount   = customer.AvailableAmount;
                customerViewModel.AvailablePoint    = customer.AvailablePoint;
                customerViewModel.AvailableTVR      = customer.AvailableTVR;
                customerViewModel.AgentCode         = customer.AgentCode;
                customerViewModel.AgentName         = customer.AgentName;
                customerViewModel.IntroducerCode    = customer.IntroduceCode;
                customerViewModel.IntroducerName    = customer.IntroduceName;


                return(View(customerViewModel));
            }
        }
예제 #2
0
        public ActionResult SignUp()
        {
            SignUpViewModel signupViewModel = new SignUpViewModel();

            using (var db = new TourEntities())
            {
                List <string> topUpAmount = new List <string>();

                int?minTopUpAmount = db.SystemSetting.OrderByDescending(x => x.CreadtedDate).FirstOrDefault().MinAmount;

                if (minTopUpAmount != null)
                {
                    topUpAmount.Add(minTopUpAmount.ToString());

                    for (int i = 1; i <= 4; i++)
                    {
                        minTopUpAmount += minTopUpAmount;
                        topUpAmount.Add(minTopUpAmount.ToString());
                    }

                    topUpAmount.Add("Other");
                }

                signupViewModel.TopUpAmount = topUpAmount.ToList().Select(e => new SelectListItem()
                {
                    Text  = e.ToString(),
                    Value = e.ToString(),
                }).ToList();
            }


            return(View(signupViewModel));
        }
예제 #3
0
        public ActionResult IntroducerTransaction(int userId)
        {
            using (var db = new TourEntities())
            {
                var customer = db.Customer.Where(x => x.UserId == userId).FirstOrDefault();

                List <IntroducerTransactionViewModel> introducerTransaction = (from data in db.IntroducerTransaction
                                                                               where data.IntroducerId == customer.CustomerId
                                                                               select new IntroducerTransactionViewModel()
                {
                    IntroducerTransactionId = data.IntroducerTransactionId,
                    IntroducerId = data.IntroducerId,
                    CreditAmount = data.CreditAmount,
                    FinalAmount = data.FinalAmount,
                    DebitAmount = data.DebitAmount,
                    CreditTVR = data.CreditTVR,
                    DebitTVR = data.DebitTVR,
                    FinalTVR = data.FinalTVR,
                    CreditPoint = data.CreditPoint,
                    DebitPoint = data.DebitPoint,
                    FinalPoint = data.FinalPoint,
                    CreatedAt = data.CreatedAt,
                    CreatedBy = data.CreatedBy
                }).ToList();
                return(View(introducerTransaction));
            }
        }
예제 #4
0
        public ActionResult ViewDetail()
        {
            using (var db = new TourEntities())
            {
                User user = MetadataServices.GetCurrentUser();
                var  role = db.Role.FirstOrDefault(e => e.RoleId.Equals(user.RoleId));


                if (role.RoleName == TourRole.Admin)
                {
                    return(RedirectToAction("Index", "Admin"));
                }
                else if (role.RoleName == TourRole.Superadmin)
                {
                    return(RedirectToAction("Index", "Admin"));
                }
                else if (role.RoleName == TourRole.Agent)
                {
                    return(RedirectToAction("AgentTransaction", "Agent"));
                }
                else if (role.RoleName == TourRole.Customer)
                {
                    return(RedirectToAction("TravelPromotion", "Customer"));
                }
                else
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }
        }
예제 #5
0
        public ActionResult ViewPackageDetail(int packageId)
        {
            using (var db = new TourEntities())
            {
                var package = db.Package.Where(x => x.PackageId == packageId).FirstOrDefault();

                ViewPackageViewModel packageViewModel = new ViewPackageViewModel();

                packageViewModel.PackageId       = package.PackageId;
                packageViewModel.PackageName     = package.PackageName;
                packageViewModel.Description     = package.Description;
                packageViewModel.IteneraryDetail = package.IteneraryDetail;
                packageViewModel.PhotoPath       = package.PhotoPath;
                packageViewModel.FilePath        = package.FilePath;
                packageViewModel.TVR             = package.TVR;
                packageViewModel.Amount          = package.Amount;

                List <string> personAmount = new List <string>();

                for (int i = 1; i <= 5; i++)
                {
                    personAmount.Add(i.ToString());
                }

                personAmount.Add("Other");

                packageViewModel.PersonAmount = personAmount.ToList().Select(e => new SelectListItem()
                {
                    Text  = e.ToString(),
                    Value = e.ToString(),
                }).ToList();

                return(View(packageViewModel));
            }
        }
예제 #6
0
        public ActionResult EditProductRedeem(int id)
        {
            using (var db = new TourEntities())
            {
                var productRedeem = db.ProductRedeem.Where(e => e.ProductRedeemId == id).FirstOrDefault();

                if (productRedeem == null)
                {
                    return(new HttpNotFoundResult("Product Redeem not found"));
                }

                return(View(new ProductRedeemViewModel()
                {
                    ProductRedeemId = productRedeem.ProductRedeemId,
                    ProductRedeemName = productRedeem.ProductRedeemName,
                    RedeemPoint = productRedeem.RedeemPoint,
                    Stock = productRedeem.Stock,
                    ImagePath = productRedeem.ImagePath,
                    CreatedBy = productRedeem.CreatedBy,
                    CreatedAt = productRedeem.CreatedAt,
                    UpdatedBy = productRedeem.UpdatedBy,
                    UpdatedAt = productRedeem.UpdatedAt
                }));
            }
        }
예제 #7
0
        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());
                }
            }
        }
예제 #8
0
        public ActionResult UpdateAgentProfile()
        {
            using (var db = new TourEntities())
            {
                int userId = MetadataServices.GetCurrentUser().UserId;

                var agent = db.Agent.Where(x => x.UserId == userId).FirstOrDefault();
                if (agent == null)
                {
                    return(new HttpNotFoundResult("Agent not found"));
                }
                var user = db.User.Where(e => e.UserId == agent.UserId).FirstOrDefault();

                return(View(new EditAgentProfileViewModel()
                {
                    AgentId = agent.AgentId,
                    EmailAddress = user.EmailAddress,
                    DOB = agent.DOB,
                    DOBString = agent.DOB.ToString("yyyy-MM-dd HH:mm"),
                    AgentName = agent.AgentName,
                    BankName = agent.BankName,
                    BankAccountNumber = agent.BankAccountNumber,
                    Address = agent.Address,
                    NRIC = agent.NRIC,
                    PhoneNumber = agent.PhoneNumber,
                    UserId = user.UserId
                }));
            }
        }
예제 #9
0
        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));
            }
        }
예제 #10
0
        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;
            }
        }
예제 #11
0
        public async System.Threading.Tasks.Task <JsonResult> SendBirthdayWishes()
        {
            try
            {
                using (var db = new TourEntities())
                {
                    var currentDate      = MetadataServices.GetCurrentDate();
                    var customerBirthday = db.Customer.Where(e => e.DateOfBirth.Month.Equals(currentDate.Month) && e.DateOfBirth.Day.Equals(currentDate.Day)).ToList();
                    foreach (var customer in customerBirthday)
                    {
                        var user = db.User.FirstOrDefault(e => e.UserId == customer.UserId);
                        if (user == null)
                        {
                            continue;
                        }
                        MetadataServices.SendWhatsappMessage("Hi " + customer.CustomerName + ", Happy Birthday to you.", customer.PhoneNumber);;
                        await MetadataServices.SendEmail(user.EmailAddress, "Wishes from EnjoyOurTour", "Hi " + customer.CustomerName + ", <br/><br/>Happy Birthday to you!");
                    }
                    return(Json(new { status = "success" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { status = "failed" }, JsonRequestBehavior.AllowGet));

                throw;
            }
        }
예제 #12
0
        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());
                }
            }
        }
예제 #13
0
        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));
            }
        }
예제 #14
0
        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());
                }
            }
        }
예제 #15
0
        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));
            }
        }
예제 #16
0
        public ActionResult EditMerchant(int id)
        {
            using (var db = new TourEntities())
            {
                var merchant = db.Merchant.Where(e => e.MerchantId == id).FirstOrDefault();

                if (merchant == null)
                {
                    return(new HttpNotFoundResult("Merchant not found"));
                }

                List <int> merchantCategory = new List <int>();

                return(View(new AddMerchantViewModel()
                {
                    MerchantId = merchant.MerchantId,
                    MerchantName = merchant.MerchantName,
                    MerchantRegisterCode = merchant.MerchantRegisterCode,
                    MerchantPhoneNumber = merchant.MerchantPhoneNumber,
                    MerchantAddress = merchant.MerchantAddress,
                    MerchantCategoryId = db.MerchantCategory.Select(e => new SelectListItem()
                    {
                        Text = e.CategoryName.ToString(),
                        Value = e.MerchantCategoryId.ToString(),
                    }).ToList(),
                    GetMerchantCategoryId = merchant.MerchantCategoryId,
                    displayMerchantJoinDate = merchant.MerchantJoinDate.ToString("yyyy-MM-dd HH:mm")
                }));
            }
        }
예제 #17
0
        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));
            }
        }
예제 #18
0
 public ActionResult Index()
 {
     using (var db = new TourEntities())
     {
         var banners = (from e in db.Banner
                        where e.IsActive
                        select new BannerViewModel()
         {
             BannerDescription = e.BannerDescription,
             BannerImage = e.BannerImage,
         }).ToList();
         var aboutUs = db.AboutUs.Select(e => new AboutUsViewModel
         {
             AboutUsTitle            = e.AboutUsTitle,
             AboutUsDescription      = e.AboutUsDescription,
             AboutUsShortDescription = e.AboutUsShortDescription,
             YoutubeUrl = e.YoutubeLink,
         }).FirstOrDefault();
         var contact = db.ContactUs.Select(e => new ContactUsViewModel()
         {
             ContactUsTitle     = e.ContactUsTitle,
             CompanyName        = e.CompanyName,
             CompanyAddress     = e.CompanyAddress,
             CompanyPhoneNumber = e.CompanyPhoneNumber,
             CompanyLatitude    = e.CompanyLatitude,
             CompanyLongitude   = e.CompanyLongitude,
         }).FirstOrDefault();
         return(View(new HomeViewModel()
         {
             Banners = banners,
             AboutUs = aboutUs,
             ContactUs = contact,
         }));
     }
 }
예제 #19
0
        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());
                }
            }
        }
예제 #20
0
        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));
                }
            }
        }
예제 #21
0
        public ActionResult RedeemCoupon()
        {
            using (var db = new TourEntities())
            {
                RedeemCouponViewModel redeemCouponViewModel = new RedeemCouponViewModel();

                return(View(redeemCouponViewModel));
            }
        }
예제 #22
0
 public static string GetUsername(string id)
 {
     using (var db = new TourEntities())
     {
         var userId   = Convert.ToInt64(id);
         var username = (from u in db.User
                         where u.UserId == userId
                         select u.Username).FirstOrDefault();
         return(username);
     }
 }
예제 #23
0
        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;
            }
        }
예제 #24
0
        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;
            }
        }
예제 #25
0
        public ActionResult ViewCustomerTestimony(int testimonyId)
        {
            using (var db = new TourEntities())
            {
                var testimony = db.CustomersTestimony.Where(x => x.TestimonyId == testimonyId).FirstOrDefault();

                ViewCustomerTestimonyViewModel testimonyViewModel = new ViewCustomerTestimonyViewModel();

                testimonyViewModel.TestimonyId = testimony.TestimonyId;
                testimonyViewModel.Description = testimony.Description;
                testimonyViewModel.YouTubeLink = testimony.YoutubeLink;
                testimonyViewModel.PhotoPath   = testimony.PhotoPath;

                return(View(testimonyViewModel));
            }
        }
예제 #26
0
        public ActionResult MerchantCategory()
        {
            using (var db = new TourEntities())
            {
                List <MerchantCategoryViewModel> merchantCategory = (from data in db.MerchantCategory
                                                                     select new MerchantCategoryViewModel()
                {
                    MerchantCategoryId = data.MerchantCategoryId,
                    CategoryName = data.CategoryName,
                    CreatedAt = data.CreatedAt
                }).ToList();


                return(View(merchantCategory));
            }
        }
예제 #27
0
        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));
                }
            }
        }
예제 #28
0
        public ActionResult ViewPointRedemption(int productId)
        {
            using (var db = new TourEntities())
            {
                var product = db.ProductRedeem.Where(x => x.ProductRedeemId == productId).FirstOrDefault();

                ViewPointRedemption pointRedemptionViewModel = new ViewPointRedemption();

                pointRedemptionViewModel.ProductRedeemId   = product.ProductRedeemId;
                pointRedemptionViewModel.RedeemPoint       = product.RedeemPoint;
                pointRedemptionViewModel.ProductRedeemName = product.ProductRedeemName;
                pointRedemptionViewModel.RedeemPoint       = product.RedeemPoint;
                pointRedemptionViewModel.ImagePath         = product.ImagePath;

                return(View(pointRedemptionViewModel));
            }
        }
예제 #29
0
        public ActionResult AddMerchant()
        {
            AddMerchantViewModel addMerchantVideModel = new AddMerchantViewModel();

            List <int> merchantCategory = new List <int>();

            using (var db = new TourEntities())
            {
                addMerchantVideModel.MerchantCategoryId = db.MerchantCategory.Select(e => new SelectListItem()
                {
                    Text  = e.CategoryName.ToString(),
                    Value = e.MerchantCategoryId.ToString(),
                }).ToList();
            }

            return(View(addMerchantVideModel));
        }
예제 #30
0
        public ActionResult AddMerchantPromotion()
        {
            AddMerchantPromotionViewModel addMerchantPromoViewModel = new AddMerchantPromotionViewModel();

            List <int> merchantId = new List <int>();

            using (var db = new TourEntities())
            {
                addMerchantPromoViewModel.MerchantIdList = db.Merchant.Select(e => new SelectListItem()
                {
                    Text  = e.MerchantName.ToString(),
                    Value = e.MerchantId.ToString(),
                }).ToList();
            }

            return(View(addMerchantPromoViewModel));
        }