Exemplo n.º 1
0
        public async Task <IActionResult> EditProperty(PropertySupervisorViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var propertySupervisor = await _converterHelper.ToPropertySupervisorAsync(viewModel, false);

                _dataContext.PropertySupervisors.Update(propertySupervisor);
                await _dataContext.SaveChangesAsync();

                return(RedirectToAction("Details", "Supervisors", new { id = viewModel.SupervisorId }));
            }

            return(View(viewModel));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AddProperty(PropertySupervisorViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var propertySupervisor = await _converterHelper.ToPropertySupervisorAsync(viewModel, true);

                _dataContext.PropertySupervisors.Add(propertySupervisor);
                await _dataContext.SaveChangesAsync();

                return(RedirectToAction("Details", "Supervisors", new { id = viewModel.SupervisorId }));
            }

            viewModel.PropertyTypes = _combosHelper.GetComboPropertyTypes();

            return(View(viewModel));
        }
Exemplo n.º 3
0
 public async Task <PropertySupervisor> ToPropertySupervisorAsync(PropertySupervisorViewModel viewModel, bool isNew)
 {
     return(new PropertySupervisor
     {
         Id = isNew ? 0 : viewModel.SupervisorId,
         Serie = viewModel.Serie,
         Company = viewModel.Company,
         Model = viewModel.Model,
         Colour = viewModel.Colour,
         IsAvailable = viewModel.IsAvailable,
         Price = viewModel.Price,
         Supervisor = await _dataContext.Supervisors.FindAsync(viewModel.SupervisorId),
         PropertyType = await _dataContext.PropertyTypes.FindAsync(viewModel.PropertyTypeId),
         PropertySupervisorImages = isNew ? new List <PropertySupervisorImage>() : viewModel.PropertySupervisorImages,
         Remarks = viewModel.Remarks
     });
 }
Exemplo n.º 4
0
        public async Task <IActionResult> AddProperty(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var supervisor = await _dataContext.Supervisors.FindAsync(id);

            if (supervisor == null)
            {
                return(NotFound());
            }
            var model = new PropertySupervisorViewModel
            {
                SupervisorId  = supervisor.Id,
                PropertyTypes = _combosHelper.GetComboPropertyTypes()
            };

            return(View(model));
        }