public ActionResult CompanyDetails(string data) { CompanyViewModel comapnyDetail = new CompanyViewModel(); Qparams qparams = null; if (!string.IsNullOrWhiteSpace(data)) { qparams = Helper.Helper.DecryptParamData <Qparams>(data); } TempData.Remove("qparams"); TempData["qparams"] = qparams; TempData.Keep("qparams"); var values = from Enums.BookingType e in Enum.GetValues(typeof(Enums.BookingType)) select new { ID = (int)Enum.Parse(typeof(Enums.BookingType), e.ToString()), Name = e.ToString() }; ViewBag.CompanyList = new SelectList(values, "Id", "Name"); ViewBag.StateList = _IMasterService.GetStateList(1); ViewBag.RailRoads = _IMasterService.GetRailRoads(); if (qparams.Id != null) { comapnyDetail = _IMasterService.GetCompanyById((int)qparams.Id).FirstOrDefault(); ViewBag.RailRoads = _IMasterService.GetRailRoadsByCompany((long)qparams.CompanyId); return(View(comapnyDetail)); } else { return(View(comapnyDetail)); } }
private List <UserTypeViewModel> GetUserTypes(Qparams qparams) { List <UserTypeViewModel> userTypes = new List <UserTypeViewModel>(); string[] roles = null; if (!string.IsNullOrWhiteSpace(qparams.UserType)) { userTypes = _IUserService.GetUserTypes().Where(item => item.Code == qparams.UserType).ToList(); } else { if (UserAuthenticate.Role == AppConstant.RoleAdmin) { roles = new string[] { AppConstant.RoleEmployee, AppConstant.RoleDriver }; userTypes = _IUserService.GetUserTypes().Where(item => roles.Contains(item.Code)).ToList(); } else if (UserAuthenticate.Role == AppConstant.RoleEmployee) { roles = new string[] { AppConstant.RoleDriver }; userTypes = _IUserService.GetUserTypes().Where(item => roles.Contains(item.Code)).ToList(); } else { //userTypes = _IUserService.GetUserTypes().Where(item => item.Code == qparams.UserType).ToList(); userTypes = _IUserService.GetUserTypes().ToList(); } } return(userTypes); }
public ActionResult ManageCompany(string sortOrder, int?page, int?pageSize, string data, string search) { int pageDataSize = (pageSize ?? 10); int pageNumber = (page ?? 1); ViewBag.CurrentSort = sortOrder; ViewBag.PageSize = pageDataSize; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "CreatedOn_desc" : ""; Qparams qparams = null; if (!string.IsNullOrWhiteSpace(data)) { qparams = Helper.Helper.DecryptParamData <Qparams>(data); } TempData.Remove("qparams"); TempData["qparams"] = qparams; TempData.Keep("qparams"); SearchingParams searchingParams = Helper.Helper.GetParamData <SearchingParams>(search); var list = _IMasterService.GetCompanyById(0).OrderByDescending(item => item.Id).ToPagedList(pageNumber, pageDataSize); return(Request.IsAjaxRequest() ? (ActionResult)PartialView("_Companies", list) : View(list)); }
public ActionResult UserDetails(string data) { Qparams qparams = new Qparams(); DateTime From = DateTime.MinValue, To = DateTime.MinValue; if (!string.IsNullOrWhiteSpace(data)) { qparams = Helper.DecryptParamData <Qparams>(data); } //qparams.UserType = "Admin"; TempData.Remove("qparams"); TempData["qparams"] = qparams; TempData.Keep("qparams"); ViewBag.UserTypes = GetUserTypes(qparams); // GetDefaultData(); if (qparams.Id != null) { UserViewModel userDetail = new UserViewModel(); userDetail = _IUserService.GetUsersDetailsById((int)qparams.Id); userDetail.ConfirmEmail = userDetail.Email; userDetail.ConfirmPassword = userDetail.Password; return(View(userDetail)); } else { return(View(new UserViewModel())); } }
public ActionResult ManageUsers(string sortOrder, int?page, int?pageSize, string data, string search) { int pageDataSize = (pageSize ?? 10); int pageNumber = (page ?? 1); ViewBag.CurrentSort = sortOrder; ViewBag.PageSize = pageDataSize; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "CreatedOn_desc" : ""; Qparams qparams = new Qparams(); if (!string.IsNullOrWhiteSpace(data)) { qparams = Helper.DecryptParamData <Qparams>(data); } qparams.UserType = AppConstant.RoleDriver; TempData.Remove("qparams"); TempData["qparams"] = qparams; TempData.Keep("qparams"); SearchingParams searchingParams = Helper.GetParamData <SearchingParams>(search); searchingParams.ReportingTo = Convert.ToInt64(UserAuthenticate.LogId); if (qparams.AccountStatus != null) { searchingParams.AccountStatus = qparams.AccountStatus; } searchingParams.UserTypeCode = string.Empty; searchingParams.LoggedUserTypeCode = UserAuthenticate.Role; if (!string.IsNullOrWhiteSpace(qparams.UserType)) { //if (!string.IsNullOrWhiteSpace(qparams.UserType)) //{ // searchingParams.UserTypeCode = qparams.UserType.Trim(); //} } else { List <UserTypeViewModel> userTypes = GetUserTypes(qparams); ViewBag.UserTypes = userTypes; if (searchingParams.UserTypeId == null || searchingParams.UserTypeId?.Count == 0) { searchingParams.UserTypeId = userTypes.Select(item => item.Id).ToList(); } } var list = _IUserService.GetAllUsers(searchingParams).OrderBy(x => x.FullName).ToPagedList(pageNumber, pageDataSize); return(Request.IsAjaxRequest() ? (ActionResult)PartialView("_Users", list) : View(list)); }
public ActionResult UserDetails(string data) { float? CostPerMile = 0; float? CostPerMinute = 0; Qparams qparams = null; DateTime From = DateTime.MinValue, To = DateTime.MinValue; if (!string.IsNullOrWhiteSpace(data)) { qparams = Helper.Helper.DecryptParamData <Qparams>(data); } TempData.Remove("qparams"); TempData["qparams"] = qparams; TempData.Keep("qparams"); ViewBag.UserTypes = GetUserTypes(qparams); // GetDefaultData(); if (qparams.Id != null) { UserViewModel userDetail = new UserViewModel(); userDetail = _IUserService.GetUsersDetailsById((int)qparams.Id); userDetail.ConfirmEmail = userDetail.Email; userDetail.ConfirmPassword = userDetail.Password; userDetail.DriverHistory = _IUserService.GetVehiclesByDriverId((int)qparams.Id); if (userDetail.UserDetails != null) { if (userDetail.UserDetails.CostPerMile != null) { CostPerMile = userDetail.UserDetails.CostPerMile; } if (userDetail.UserDetails.CostPerMinute != null) { CostPerMinute = userDetail.UserDetails.CostPerMinute; } } userDetail.WeeklyPerformanceList = _IUserService.GetPerformaceListByDriverId((int)qparams.Id, CostPerMile, CostPerMinute, From, To); //GetAddressDefaultEditData(userDetail.UserDetail); return(View(userDetail)); } else { return(View(new UserViewModel())); } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.ActionParameters.ContainsKey(ParamName)) { var data = filterContext.ActionParameters[ParamName] as string; Qparams qparams = null; if (!string.IsNullOrWhiteSpace(data)) { qparams = Helper.DecryptParamData <Qparams>(data); if (UserAuthenticate.LogId != qparams.LogId?.ToString()) { HandleUnauthorizedRequest(filterContext); } } } return; //base.OnActionExecuting(filterContext); }
public ActionResult CustomerDetails(string data) { Qparams qparams = null; if (!string.IsNullOrWhiteSpace(data)) { qparams = Helper.Helper.DecryptParamData <Qparams>(data); } TempData.Remove("qparams"); TempData["qparams"] = qparams; TempData.Keep("qparams"); // ViewBag.UserTypes = GetUserTypes(qparams); GetDefaultData(); if (qparams != null) { if (qparams.Id != null) { ViewBag.Title = "Update Information"; UserViewModel userDetail = new UserViewModel(); userDetail = _IUserService.GetUsersDetailsById((int)qparams.Id); userDetail.ConfirmEmail = userDetail.Email; userDetail.ConfirmPassword = userDetail.Password; //GetAddressDefaultEditData(userDetail.UserDetail); return(View(userDetail)); } else { return(View()); } } else { ViewBag.Title = "Create new user"; return(View()); } }
public ActionResult CompanyDetails(CompanyViewModel company) { Qparams qparams = null; if (TempData["qparams"] != null) { qparams = TempData["qparams"] as Qparams; TempData.Keep("qparams"); } string responseMsg = string.Empty; MyJsonResult result; TempData.Remove("result"); bool resultStatus = false; string mailBody = string.Empty; if (company.Id == 0) { ModelState.Remove("Id"); } if (ModelState.IsValid) { if (company.Name == Enums.BookingType.Halcon.ToString()) { company.CompanyId = (int)Enums.BookingType.Halcon; } else if (company.Name == Enums.BookingType.PTI.ToString()) { company.CompanyId = (int)Enums.BookingType.PTI; } else if (company.Name == Enums.BookingType.CP.ToString()) { company.CompanyId = (int)Enums.BookingType.CP; } else { company.CompanyId = (int)Enums.BookingType.BP; } if (company.Id > 0) { company.ModifiedBy = Convert.ToInt64(UserAuthenticate.LogId); company.CreatedBy = Convert.ToInt64(UserAuthenticate.LogId); resultStatus = _IMasterService.UpdateCompany(company); responseMsg = "The company information has been updated."; } else { company.CreatedBy = Convert.ToInt64(UserAuthenticate.LogId); resultStatus = _IMasterService.SaveCompany(company); responseMsg = "The company has been created."; } result = MyJsonResult.CreateSuccess(responseMsg); TempData["result"] = result; return(RedirectToAction("ManageCompany", new { data = SecurityHelper.Encrypt(Newtonsoft.Json.JsonConvert.SerializeObject(qparams)) })); } else { result = MyJsonResult.CreateError(responseMsg); TempData["result"] = result; TempData.Keep("result"); return(View(company)); } }
public ActionResult UserDetails([Bind(Exclude = "UserType")] UserViewModel user) { Qparams qparams = new Qparams(); if (TempData["qparams"] != null) { qparams = TempData["qparams"] as Qparams; TempData.Keep("qparams"); } TempData.Remove("result"); var jsonData = SecurityHelper.Decrypt(System.Web.HttpContext.Current.Request.Cookies["ES"]["US"].ToString()); Hashtable decryptedData = JsonConvert.DeserializeObject <Hashtable>(jsonData); qparams.UserType = decryptedData["UserType"].ToString(); qparams.LogId = Convert.ToInt64(decryptedData["LogId"]); if (qparams.IsExternalDriver) { user.UserTypeId = 9; } bool resultStatus = false; string mailBody = string.Empty; ViewBag.UserTypes = GetUserTypes(qparams); if (user.ReportingTo == null) { user.ReportingTo = Convert.ToInt64(UserAuthenticate.LogId); ModelState.Remove("ReportingTo"); } if (user.Id == 0) { ModelState.Remove("Id"); } else { ModelState.Remove("Password"); ModelState.Remove("ConfirmPassword"); } if (_IUserService.IsUserExists(user.Email, user.Id.ToString())) { ModelState.AddModelError("Email", "Email is already taken by someone."); } if (ModelState.IsValid) { string responseMsg = string.Empty; MyJsonResult result; if (user.Id > 0) { user.ModifiedBy = Convert.ToInt64(UserAuthenticate.LogId); resultStatus = _IUserService.UpdateUsers(user); responseMsg = "The driver information has been updated."; } else { user.CreatedBy = Convert.ToInt64(UserAuthenticate.LogId); //mailBody = HomeController.RenderPartialToString("_accountActivationTemplate", user, ControllerContext); resultStatus = _IUserService.SaveUsers(user, Convert.ToInt64(UserAuthenticate.LogId), true, mailBody); if (resultStatus) { // sending mail to user mailBody = RenderPartialToString("_AccountCreatationNotify", user, ControllerContext); // _IMasterService.SendAccountCreatationEmail("Driver Created", mailBody, user, Convert.ToInt64(UserAuthenticate.LogId)); } responseMsg = "The driver account for " + user.FirstName + " " + user.LastName + " has been created."; } if (resultStatus) { result = MyJsonResult.CreateSuccess(responseMsg); TempData["result"] = result; TempData.Keep("result"); if (user.UserTypeId == 9) { return(RedirectToAction("ManageExternalDriver", "ExternalTrip", new { data = SecurityHelper.Encrypt(Newtonsoft.Json.JsonConvert.SerializeObject(qparams)) })); } return(RedirectToAction("ManageUsers", new { data = SecurityHelper.Encrypt(Newtonsoft.Json.JsonConvert.SerializeObject(qparams)) })); } else { result = MyJsonResult.CreateError(AppConstant.ErrorMessage); TempData["result"] = result; TempData.Keep("result"); return(View(user)); } } else { //GetAddressDefaultEditData(user.UserDetail); return(View(user)); } }
public ActionResult CustomerDetails(CustomerViewModel customer) { Qparams qparams = null; if (TempData["qparams"] != null) { qparams = TempData["qparams"] as Qparams; TempData.Keep("qparams"); } TempData.Remove("result"); GetDefaultData(); bool resultStatus = false; string mailBody = string.Empty; //ViewBag.UserTypes = GetUserTypes(qparams); //if (customer.ReportingTo == null) //{ // customer.ReportingTo = Convert.ToInt64(UserAuthenticate.LogId); // ModelState.Remove("ReportingTo"); //} //if (customer.Id == 0) //{ // ModelState.Remove("Id"); //} //else //{ // ModelState.Remove("Password"); // ModelState.Remove("ConfirmPassword"); //} //if (_IUserService.RegionAssigned(user.Id, user.AssignedRegionId, user.UserTypeId)) // ModelState.AddModelError("AssignedRegionId", "Regional Manager is already assigned to this region."); if (_IUserService.IsUserExists(customer.Email, customer.Id.ToString())) { ModelState.AddModelError("Email", "Email is already taken by someone."); } if (customer.Id == 0) { ModelState.Remove("Id"); } if (ModelState.IsValid) { string responseMsg = string.Empty; // User IsAuthenticatedUser = new User(); // IsAuthenticatedUser = _IUserService.UserAuthentication(user); MyJsonResult result; if (customer.Id > 0) { // customer.ModifiedBy = Convert.ToInt64(UserAuthenticate.LogId); resultStatus = _ICustomerService.UpdateCustomers(customer); responseMsg = "The Customer information has been updated."; } else { //customer.CreatedBy = Convert.ToInt64(UserAuthenticate.LogId); customer.PasswordHash = SecurityHelper.CreatePasswordHash(customer.PasswordHash, AppConfig.SaltKey); //mailBody = HomeController.RenderPartialToString("_accountActivationTemplate", user, ControllerContext); resultStatus = _ICustomerService.SaveCustomers(customer, Convert.ToInt64(UserAuthenticate.LogId), true, mailBody); responseMsg = "The Customer account for " + customer.FirstName + " " + customer.LastName + " has been created."; } if (resultStatus) { result = MyJsonResult.CreateSuccess(responseMsg); TempData["result"] = result; TempData.Keep("result"); return(RedirectToAction("ManageUsers", new { data = SecurityHelper.Encrypt(Newtonsoft.Json.JsonConvert.SerializeObject(qparams)) })); } else { result = MyJsonResult.CreateError(AppConstant.ErrorMessage); TempData["result"] = result; TempData.Keep("result"); return(View(customer)); } } else { //GetAddressDefaultEditData(user.UserDetail); return(View(customer)); } }
public ActionResult UserProfileInfo(UserViewModel user) { Qparams qparams = null; if (TempData["qparams"] != null) { qparams = TempData["qparams"] as Qparams; TempData.Keep("qparams"); } TempData.Remove("result"); bool resultStatus = false; ModelState.Remove("ConfirmPassword"); ModelState.Remove("Password"); ModelState.Remove("ConfirmEmail"); ModelState.Remove("Email"); ModelState.Remove("ReportingTo"); //Medium profilePhoto = new Medium(); //HttpPostedFileBase imgFile = Request.Files["imageProfilePhoto"]; //if (imgFile != null && imgFile.ContentLength > 0) //{ // if (user.Id > 0) // profilePhoto.MediaForId = user.Id; // profilePhoto.MediaFor = (int)Utility.Enums.MediaFor.UserProfile; // profilePhoto.MediaType = (int)Utility.Enums.MediaType.Image; // profilePhoto.ImageType = (int)Utility.Enums.ImageType.UserProfile; // profilePhoto.MimeType = string.Empty; // profilePhoto.ContentType = imgFile.ContentType; // profilePhoto.FileName = imgFile.FileName; // profilePhoto.ImageBinary = CommonHelper.ConvertToBytes(imgFile); // profilePhoto.IsActive = true; //} if (ModelState.IsValid) { string responseMsg = string.Empty; MyJsonResult result; if (user.Id > 0) { user.ModifiedBy = Convert.ToInt64(UserAuthenticate.LogId); resultStatus = _IUserService.UpdateUsers(user); responseMsg = "The user information has been updated."; } if (resultStatus) { result = MyJsonResult.CreateSuccess(responseMsg); TempData["result"] = result; TempData.Keep("result"); return(RedirectToAction("UserProfileInfo")); } else { result = MyJsonResult.CreateError(AppConstant.ErrorMessage); TempData["result"] = result; TempData.Keep("result"); return(View(user)); } } return(View(user)); }