public ActionResult SpecialistRegisterStep1(SpecialistRegisterStep2ViewModel model) { try { ViewBag.MaximumSize = Services.SystemConfig.GetValueByKey(TeleConsult.Infrastructure.Core.Const.SystemConfig.FILE_UPLOAD_LIMITS); var user = Services.Users.GetUserById(CurrentUser.Id); var listLocation = new List<LocationDto>(); Mapper.CreateMap<LocationViewModel, LocationDto>() .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id)); foreach (var item in model.Locations) { item.TimeZone = model.TimeZone; var loc = Mapper.Map<LocationViewModel, LocationDto>(item); loc.CreatedDate = DateTime.UtcNow; loc.ModifiedDate = DateTime.UtcNow; listLocation.Add(loc); } if (model.GST && string.IsNullOrWhiteSpace(model.ABN)) { return Json(new { Success = false, Message = "ABN/ACN required." }, JsonRequestBehavior.AllowGet); } user.Title = model.Title; user.FirstName = model.FirstName; user.LastName = model.LastName; user.Locations = listLocation; user.CompletedStep = Step.Step1; user.PostNominal = model.PostNominal; user.Profiles = new List<ProfileDto> { new ProfileDto { ABN = model.GST ? model.ABN : string.Empty, GstRegistered = model.GST } }; if (Services.Users.UpdateUserInfo(user)) { return RedirectToAction("SpecialistRegisterStep2", "SpecialistRegistration", new { id = CurrentUser.Id }); } } catch (Exception e) { // Log Log.Error("SpecialistRegisterStep1. Error: ", e); } return RedirectToAction("Error", "Error"); }
public ActionResult SpecialistRegisterStep1(Guid id) { ViewBag.MaximumSize = Services.SystemConfig.GetValueByKey(TeleConsult.Infrastructure.Core.Const.SystemConfig.FILE_UPLOAD_LIMITS); var user = Services.Users.GetUserById(id); if (user == null) { //TODO: return error or some message return RedirectToAction("Register", "Account"); } var model = new SpecialistRegisterStep2ViewModel(); if (user.Locations != null && user.Locations.Any()) { Mapper.CreateMap<LocationDto, LocationViewModel>() .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id)); List<LocationViewModel> locations = new List<LocationViewModel>(); foreach (var location in user.Locations) { locations.Add(Mapper.Map<LocationDto, LocationViewModel>(location)); } model.Locations = locations; model.Title = user.Title; model.FirstName = user.FirstName; model.LastName = user.LastName; model.PostNominal = user.PostNominal; model.ABN = user.Profiles[0].ABN; model.GST = user.Profiles[0].GstRegistered; model.TimeZone = user.Locations[0].TimeZone; } else { model.Locations = new List<LocationViewModel> { new LocationViewModel() }; } model.AvatarPath = user.Avatar != null ? Path.Combine(BlueChilli.Web.Helpers.S3PathWithoutQuery("").Substring(1), user.Avatar) : ConstPath.DefaulAvatar; return View(model); }