public static bool IsShowingFlightAcc(Models.DB.Registration regItem) { bool result = true; // TODO: check if reg item progress contains "Flight & Acc" step, this may related to promo code return(result); }
public ActionResult Register ( string id, string name, string designation, string mobile, string email, string organisation, HttpPostedFileBase file ) { string Validation = ValidateRegistration(name, designation, mobile, email, organisation); List <Registration> regList = null; if (!String.IsNullOrEmpty(id) && !Validate.IsRegFormOpenForm(id)) { Guid _id = Guid.Empty; Guid.TryParse(id, out _id); regList = unitOfWork.RegistrationRepository.Get(filter: x => x.Email == email && x.Id != _id).ToList(); if (regList.Count > 0) { return(Json(new { success = false, errorMessage = "You are already registered." })); } } else if (!String.IsNullOrEmpty(id) && Validate.IsRegFormOpenForm(id)) { regList = unitOfWork.RegistrationRepository.Get(filter: x => x.Email == email).ToList(); if (regList.Count > 0) { return(Json(new { success = false, errorMessage = "You are already registered." })); } } if (file != null && file.ContentLength > 0) { var extention = Path.GetExtension(file.FileName); var allowedExtensions = new[] { ".jpg", ".jpeg" }; if (!allowedExtensions.Contains(extention.ToLower())) { Validation += "Please upload .jpg, or .jpeg only.\n"; } if (file.ContentLength > (7 * 1024 * 1024)) { Validation += "Photo exceed 6 MB.\n"; } } //else if (!Security.IsAdminLogin() && file.ContentLength <= 0) // comment, user request not mandatory on 17/10/2019 //{ // Validation += "Please provide your photo.\n"; //} if (!String.IsNullOrEmpty(Validation)) { return(Json(new { success = false, errorMessage = Validation })); } OLHTX2019.Models.DB.Registration reg = null; if (!String.IsNullOrEmpty(id) && !Validate.IsRegFormOpenForm(id)) { Guid _id = Guid.Empty; Guid.TryParse(id, out _id); reg = unitOfWork.RegistrationRepository.GetByID(_id); if (!Security.IsAdminLogin()) { if (reg.Status == RegStatus.OK.ToString()) { return(Json(new { success = false, errorMessage = "throw-to-thanks" })); // to handle if user go back form end page to reg form } } reg.DateModified = DateTime.Now; reg.Id = _id; } else { reg = new Models.DB.Registration(); reg.Id = Guid.NewGuid(); reg.DateSubmited = DateTime.Now; reg.DateCreated = DateTime.Now; reg.IsOpenForm = true; //flag for who register from open form } reg.Name = name; reg.Designation = designation; //reg.IDType = idType; //reg.IDNumber = idNumber; reg.Mobile = mobile; reg.Email = email; reg.Organisation = organisation; if (file != null && file.ContentLength > 0) { reg.ImageName = Path.GetFileName(file.FileName); reg.ImageType = file.ContentType; byte[] bytes; using (BinaryReader br = new BinaryReader(file.InputStream)) { bytes = br.ReadBytes(file.ContentLength); } reg.Image = bytes; } if (!Validate.IsRegFormOpenForm(id)) { unitOfWork.RegistrationRepository.Update(reg); Logging.CreateAuditLog(reg.Id, Security.IsAdminLogin() == true ? Security.GetCurrentUser() : "", "Update on Memory step1", Module.FrontEnd, unitOfWork); } else { unitOfWork.RegistrationRepository.Insert(reg); Logging.CreateAuditLog(reg.Id, "", "Insert on Memory step1", Module.FrontEnd, unitOfWork); } unitOfWork.Save(); if (String.IsNullOrEmpty(reg.SerialNo) && !Security.IsAdminLogin()) { reg.SerialNo = GeneralHelper.GenerateSerial(unitOfWork); Logging.CreateAuditLog(reg.Id, "", "Update Serial No on Memory step2 to= " + reg.SerialNo, Module.FrontEnd, unitOfWork); reg.DateSubmited = DateTime.Now; reg.Status = RegStatus.OK.ToString(); Logging.CreateAuditLog(reg.Id, "", "Update status on Memory step3 to= " + reg.Status, Module.FrontEnd, unitOfWork); reg.StepsAction = RegStepAction.CPLT.ToString(); // Complete Logging.CreateAuditLog(reg.Id, "", "Update Step action on Memory step4 to= " + reg.StepsAction, Module.FrontEnd, unitOfWork); unitOfWork.Save(); Logging.CreateAuditLog(reg.Id, "", "Save SerialNo, Status, StepAction step5 = " + reg.SerialNo + reg.Status + reg.StepsAction, Module.FrontEnd, unitOfWork); } if (reg.Status == RegStatus.OK.ToString() && !Security.IsAdminLogin()) { Logging.CreateAuditLog(reg.Id, "", "Prepare Send Email step6", Module.FrontEnd, unitOfWork); Email.SendConfirmation(reg.Id, unitOfWork); Logging.CreateAuditLog(reg.Id, "", "Email Sent step7", Module.FrontEnd, unitOfWork); } string redirect = ""; if (Security.IsAdminLogin()) { redirect = "/Admin20191008/Dashboard"; } else { redirect = "/Registration/End"; } return(Json(new { success = true, urlRed = redirect })); }