public ActionResult OwnerInfo(Guid?equipmentId, int employeeId)
        {
            try
            {
                OwnerInfoDTO ownerInfoDTO = EquipmentService.GetOwnerInfo(equipmentId, employeeId);
                OwnerInfoVM  ownerInfoVM  = Mapper.Map <OwnerInfoVM>(ownerInfoDTO);

                ViewBag.EquipmentId = equipmentId;

                return(View(ownerInfoVM));
            }
            catch (ArgumentNullException)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
        }
Exemple #2
0
        public async Task <IActionResult> OwnerInfo(OwnerInfoVM vm)
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            if (user.OwnerId != vm.Owner.OwnerId)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            var owner = await _context.Owner.SingleOrDefaultAsync(u => u.OwnerId == vm.Owner.OwnerId);

            owner.FirstName             = vm.Owner.FirstName;
            owner.LastName              = vm.Owner.LastName;
            owner.Occupation            = vm.Owner.Occupation;
            owner.Birthday              = vm.Owner.Birthday;
            owner.Email                 = vm.Owner.Email;
            owner.Phone                 = vm.Owner.Phone;
            owner.EmergencyContactName  = vm.Owner.EmergencyContactName;
            owner.EmergencyContactPhone = vm.Owner.EmergencyContactPhone;
            owner.ReceiveEmails         = vm.Owner.ReceiveEmails;
            owner.LastModifiedBy        = vm.Owner.FullName;
            owner.LastModifiedDate      = DateTime.Now;

            var addr = await _context.Address.SingleOrDefaultAsync(u => u.Id == vm.Address.Id);

            addr.StreetAddress    = vm.Address.StreetAddress;
            addr.City             = vm.Address.City;
            addr.State            = vm.Address.State;
            addr.Zip              = vm.Address.Zip;
            addr.LastModifiedBy   = owner.FullName;
            addr.LastModifiedDate = DateTime.Now;

            await _context.SaveChangesAsync();

            //return RedirectToAction("Dashboard", "General", new { area = "" });
            return(RedirectToAction("Dashboard", "OwnerPortal", new { area = "Owner" }));
        }