public async Task <IActionResult> Update(CreateOfficeViewModel vm) { var officeDto = mapper.Map <OfficeDto>(vm); await officeServices.UpdateAsync(officeDto); return(View("Manage")); }
public async Task <IActionResult> Create(CreateOfficeViewModel vm) { var officeDto = mapper.Map <OfficeDto>(vm); await officeServices.CreateAsync(officeDto); return(Redirect("/Home/Index")); }
public async Task <IActionResult> Create() { var model = new CreateOfficeViewModel() { UsersSelectList = await _dal.GetAllUsersSelectListAsync() }; return(View(model)); }
public IActionResult Post([FromBody] CreateOfficeViewModel vm) { return(ApiAction(() => { var contract = _mapper.Map <CreateOfficeContract>(vm); var returnContract = _OfficeService.Create(contract); return Created("Get", _mapper.Map <CreatedOfficeViewModel>(returnContract)); })); }
public async Task <IActionResult> Create() { var companyDtos = await companyServices.Get50Companies(0); var vm = new CreateOfficeViewModel { Companies = companyDtos.Select(c => new SelectListItem(c.Name, c.ID.ToString())).ToList() }; return(View(vm)); }
public async Task <IActionResult> Create(CreateOfficeViewModel model) { if (await _dal.OfficeNameExistsAsync(model.Name)) { ModelState.AddModelError("Name", "The name already exists."); } string msg; if (ModelState.IsValid) { var item = new Office() { Name = model.Name, MasterUserId = model.MasterUserId }; _cache.Remove(CacheKeys.OfficesSelectList); _cache.Remove(CacheKeys.OfficesSelectListRequireMaster); try { _context.Add(item); await _context.SaveChangesAsync(); msg = string.Format("The {0} has been created.", objectDisplayName); TempData.SaveAlertForSession(msg, AlertStatus.Success, "Success"); return(RedirectToAction("Details", new { id = item.Id })); } catch { msg = string.Format("There was an error saving the {0}. Please try again or contact support.", objectDisplayName); } } else { msg = string.Format("The {0} was not created. Please fix the errors shown below.", objectDisplayName); } ViewData["AlertMessage"] = new AlertViewModel(msg, AlertStatus.Error, "Error"); model.UsersSelectList = await _dal.GetAllUsersSelectListAsync(); return(View(model)); }