コード例 #1
0
        public async Task <IActionResult> AddCommitment(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var pet = await _context.Pets
                      .Include(p => p.Owner)
                      .FirstOrDefaultAsync(p => p.Id == id.Value);

            if (pet == null)
            {
                return(NotFound());
            }

            var view = new CommitmentViewModel
            {
                PetOwnerId = pet.Owner.Id,
                PetId      = pet.Id,
                Customers  = _combosHelper.GetComboCustomers(),
                Price      = 0,
                StartDate  = DateTime.Today,
                EndDate    = DateTime.Today.AddYears(1)
            };

            return(View(view));
        }
コード例 #2
0
        public async Task <IActionResult> Create()
        {
            var actualUser = await _userHelper.GetUserByEmailAsync(User.Identity.Name);

            var customer = _context.Customers.Where(c => c.User.Id == actualUser.Id);

            if (customer == null)
            {
                return(NotFound());
            }

            var model = new AppViewModel
            {
                Doctors      = _combosHelper.GetComboDoctors(),
                Customers    = _combosHelper.GetComboCustomers(),
                Pets         = _combosHelper.GetComboPets(0),
                ServiceTypes = _combosHelper.GetComboServiceTypes()
            };

            return(View(model));
        }
コード例 #3
0
 public CommitmentViewModel ToCommitmentViewModel(Commitment commitment)
 {
     return(new CommitmentViewModel
     {
         Id = commitment.Id,
         Customer = commitment.Customer,
         CustomerId = commitment.Customer.Id,
         Customers = _combosHelper.GetComboCustomers(),
         Pet = commitment.Pet,
         PetId = commitment.Pet.Id,
         PetOwner = commitment.PetOwner,
         PetOwnerId = commitment.PetOwner.Id,
         Price = commitment.Price,
         Remarks = commitment.Remarks,
         IsActive = commitment.IsActive,
         StartDate = commitment.StartDate,
         EndDate = commitment.EndDate
     });
 }
コード例 #4
0
 public AppViewModel ToAppointmentViewModel(App appointment)
 {
     return(new AppViewModel
     {
         Id = appointment.Id,
         AppDate = appointment.AppDate,
         User = appointment.User,
         Customer = appointment.Customer,
         CustomerId = appointment.Customer.Id,
         Customers = _combosHelper.GetComboCustomers(),
         Doctor = appointment.Doctor,
         DoctorId = appointment.Doctor.Id,
         Doctors = _combosHelper.GetComboDoctors(),
         Pet = appointment.Pet,
         PetId = appointment.Pet.Id,
         Pets = _combosHelper.GetComboPets(0),
         serviceType = appointment.serviceType,
         ServiveTypeId = appointment.serviceType.Id,
         ServiceTypes = _combosHelper.GetComboServiceTypes(),
     });
 }