public ActionResult EditProfile() { //UserPermissionAction("Category", RoleAction.view.ToString(), operation, ShowMessage, MessageBody); //CheckPermission(); if (Session["UserId"] == null) { return(RedirectToAction("LogOn", "Account")); } AgencyIndividualModel AgencyIndividualModels = new AgencyIndividualModel(); int id = Convert.ToInt32(Session["UserId"].ToString()); if (id > 0) { var Users = _AgencyIndividualService.GetAgencyIndividualByUserId(id); Mapper.CreateMap <AgencyIndividual, AgencyIndividualModel>(); AgencyIndividualModels = Mapper.Map <AgencyIndividual, AgencyIndividualModel>(Users); //AgencyIndividualModels.Add(_User); return(View(AgencyIndividualModels)); } else { return(RedirectToAction("LogOn", "Account")); } }
public ActionResult UpdateProfile([Bind(Include = "AgencyIndividualId,EmailId,FullName,WorkRate,ContactNumber,Address,Latitude,Longitude")] AgencyIndividualModel model, HttpPostedFileBase file) { AgencyIndividualModel agencyIndividualModel = new Models.AgencyIndividualModel(); List <CategoryModel> CategoryList = new List <CategoryModel>(); var categories = _CategoryService.GetCategories(); //UserPermissionAction("vendor", RoleAction.view.ToString(), operation, ShowMessage, MessageBody); if (string.IsNullOrEmpty(model.FullName)) { ModelState.AddModelError("FullName", ""); return(View(model)); } if (model.WorkRate == null) { ModelState.AddModelError("WorkRate", ""); return(View(model)); } if (string.IsNullOrEmpty(model.ContactNumber)) { ModelState.AddModelError("ContactNumber", ""); return(View(model)); } if (string.IsNullOrEmpty(model.Address)) { ModelState.AddModelError("Address", ""); return(View(model)); } try { if (ModelState.IsValid) { string name = ""; if (file != null && file.ContentLength > 0) { try { if (file != null && file.ContentLength > 0) { name = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName); string path = Path.Combine(Server.MapPath("~/AgencyImage"), name); file.SaveAs(path); } } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } var existingUser = _UserService.GetUserByEmailId(model.EmailId); if (existingUser != null) { existingUser.FirstName = model.FullName; existingUser.LastUpdatedOn = DateTime.Now; _UserService.UpdateUser(existingUser); var agencyIndividualDetail = _AgencyIndividualService.GetAgencyIndividualById(model.AgencyIndividualId); if (agencyIndividualDetail != null) { agencyIndividualDetail.FullName = model.FullName; agencyIndividualDetail.Address = model.Address; agencyIndividualDetail.ContactNumber = model.ContactNumber; agencyIndividualDetail.Latitude = model.Latitude; agencyIndividualDetail.Longitude = model.Longitude; agencyIndividualDetail.LastUpdatedOn = DateTime.Now; agencyIndividualDetail.WorkRate = model.WorkRate; agencyIndividualDetail.PhotoPath = name == ""?"":CommonCls.GetURL() + "/AgencyImage/" + name; _AgencyIndividualService.UpdateAgencyIndividual(agencyIndividualDetail); TempData["MessageBody"] = "Registeration done."; ViewBag.Error = TempData["MessageBody"]; return(RedirectToAction("Index")); } else { TempData["MessageBody"] = "User not found."; ViewBag.Error = TempData["MessageBody"]; return(View(model)); } } else { TempData["MessageBody"] = "User not found."; ViewBag.Error = TempData["MessageBody"]; return(View(model)); } } else { var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors); TempData["MessageBody"] = "Please fill the required fields."; ViewBag.Error = TempData["MessageBody"]; return(View(model)); } } catch (Exception ex) { string ErrorMsg = ex.Message.ToString();// ErrorLogging.LogError(ex); return(View(model)); } }
public ActionResult Details(int?key, int JobRequestId) { //UserPermissionAction("Category", RoleAction.view.ToString(), operation, ShowMessage, MessageBody); //CheckPermission(); if (Session["UserId"] == null) { return(RedirectToAction("LogOn", "Account")); } if (key == 1) { Session["CurrentPageNumber"] = null; } if (Session["CurrentPageNumber"] == null) { ViewBag.currentPageNumber = 0; } else { ViewBag.currentPageNumber = Convert.ToInt32(Session["CurrentPageNumber"]); } int id = Convert.ToInt32(Session["UserId"].ToString()); if (id > 0) { var details = new JobDetails(); var job = _RequestService.GetRequest(JobRequestId); if (job != null) { Mapper.CreateMap <JobRequest, RequestModel>(); var model = Mapper.Map <JobRequest, RequestModel>(job); var category = _CategoryService.GetCategory(model.CategoryId); if (category != null) { details.CategoryName = category.Name; } if (job.IsPaid == true) { var customerpaymentdata = _CustomerPaymentService.GetCustomerPaymentByJobRequestId(JobRequestId); Mapper.CreateMap <CustomerPayment, CustomerPaymentModel>(); CustomerPaymentModel customerPaymentModel = Mapper.Map <CustomerPayment, CustomerPaymentModel>(customerpaymentdata); details.customerPaymentModel = customerPaymentModel; } List <Reviews> objReview = new List <Reviews>(); var reviews = _ReviewAndRatingService.GetReviewAndRatings().Where(r => r.JobRequestId == JobRequestId).ToList(); float rating = 0; foreach (var review in reviews) { Mapper.CreateMap <ReviewAndRating, Reviews>(); Reviews reviewModel = Mapper.Map <ReviewAndRating, Reviews>(review); rating += Convert.ToSingle(reviewModel.Rating); var customer = _CustomerService.GetCustomer(reviewModel.CustomerId); reviewModel.CustomerName = customer.FirstName + " " + customer.LastName; reviewModel.PhotoPath = customer.PhotoPath; reviewModel.ReviewAndRatingId = review.ReviewAndRatingId; objReview.Add(reviewModel); } // DealResponseModel.AverageRating = float.IsNaN(rating / reviews.Count()) ? 0 : (rating / reviews.Count()); details.Reviews = objReview; details.TotalReviews = reviews.Count(); //START:Get detail of job assign individual AgencyJob agencyJobData = _AgencyJobService.GetAgencyJobByJobRequest(JobRequestId); if (agencyJobData != null) { var agencydata = _AgencyIndividualService.GetAgencyIndividual(agencyJobData.AgencyIndividualId); if (agencydata == null) { var customerData = _CustomerService.GetCustomer(agencyJobData.AgencyIndividualId); Mapper.CreateMap <Customer, CustomerModel>(); CustomerModel agencyModel = Mapper.Map <Customer, CustomerModel>(customerData); details.customerModel = agencyModel; } else { Mapper.CreateMap <AgencyIndividual, AgencyIndividualModel>(); AgencyIndividualModel agencyModel = Mapper.Map <AgencyIndividual, AgencyIndividualModel>(agencydata); details.agencyIndividualModel = agencyModel; } } else { details.agencyIndividualModel = null; } //END:Get detail of job assign individual details.request = model; } return(View(details)); } else { return(RedirectToAction("LogOn", "Account")); } }
public ActionResult SignUp([Bind(Include = "FullName,EmailId,Password,WorkRate,ContactNumber,Address,CategoryId,IsAgency,Latitude,Longitude")] AgencyIndividualModel model) { AgencyIndividualModel agencyIndividualModel = new Models.AgencyIndividualModel(); List <CategoryModel> CategoryList = new List <CategoryModel>(); var categories = _CategoryService.GetCategories(); //UserPermissionAction("vendor", RoleAction.view.ToString(), operation, ShowMessage, MessageBody); if (string.IsNullOrEmpty(model.FullName)) { ModelState.AddModelError("FullName", ""); return(View(model)); } if (string.IsNullOrEmpty(model.EmailId)) { ModelState.AddModelError("EmailId", ""); return(View(model)); } if (string.IsNullOrEmpty(model.Password)) { ModelState.AddModelError("Password", ""); return(View(model)); } if (model.WorkRate == null) { ModelState.AddModelError("WorkRate", ""); return(View(model)); } if (string.IsNullOrEmpty(model.ContactNumber)) { ModelState.AddModelError("ContactNumber", ""); return(View(model)); } if (string.IsNullOrEmpty(model.Address)) { ModelState.AddModelError("Address", ""); return(View(model)); } try { if (ModelState.IsValid) { var existingUser = _UserService.GetUserByEmailId(model.EmailId); if (existingUser == null) { UserModel userModel = new UserModel(); userModel.EmailId = model.EmailId; userModel.Password = SecurityFunction.EncryptString(model.Password); userModel.FirstName = model.FullName; userModel.CompanyId = 2; userModel.IsActive = true; userModel.CreatedOn = DateTime.Now; userModel.LastUpdatedOn = DateTime.Now; Mapper.CreateMap <UserModel, User>(); var User = Mapper.Map <UserModel, User>(userModel); _UserService.InsertUser(User); var getUserDetail = _UserService.GetUserByEmailId(model.EmailId); UserRoleModel userRoleModel = new UserRoleModel(); userRoleModel.UserId = getUserDetail.UserId; userRoleModel.RoleId = 4; Mapper.CreateMap <UserRoleModel, UserRole>(); var UserRole = Mapper.Map <UserRoleModel, UserRole>(userRoleModel); _UserRoleService.InsertUserRole(UserRole); model.CreatedOn = DateTime.Now; model.LastUpdatedOn = DateTime.Now; model.Password = SecurityFunction.EncryptString(model.Password); model.UserId = getUserDetail.UserId; model.IsAgency = true; model.IsActive = true; model.IsInvited = true; model.ParentId = new Guid(); Mapper.CreateMap <AgencyIndividualModel, AgencyIndividual>(); var agencyIndividual = Mapper.Map <AgencyIndividualModel, AgencyIndividual>(model); _AgencyIndividualService.InsertAgencyIndividual(agencyIndividual); TempData["MessageBody"] = "Registeration done."; ViewBag.Error = TempData["MessageBody"]; return(RedirectToAction("LogOn")); } else { TempData["MessageBody"] = "Email already exists."; ViewBag.Error = TempData["MessageBody"]; return(View(model)); } } else { TempData["MessageBody"] = "Please fill the required fields."; ViewBag.Error = TempData["MessageBody"]; return(View(model)); } } catch (Exception ex) { string ErrorMsg = ex.Message.ToString();// ErrorLogging.LogError(ex); } Mapper.CreateMap <HomeHelp.Entity.Category, HomeHelp.Models.CategoryModel>(); foreach (var category in categories) { CategoryModel categoryModel = Mapper.Map <HomeHelp.Entity.Category, HomeHelp.Models.CategoryModel>(category); CategoryList.Add(categoryModel); } model.CategoryData = CategoryList; TempData["MessageBody"] = "Something get wrong. please try again"; ViewBag.Error = TempData["MessageBody"]; return(View(model)); }