Ejemplo n.º 1
0
        public async Task <IActionResult> Create(AppViewModel model)
        {
            var appointment = _converterHelper.ToAppointment(model, true);

            if (ModelState.IsValid)
            {
                appointment.User = await _userHelper.GetUserByEmailAsync(this.User.Identity.Name);

                var customer = await _customerRepository.GetCustomerAsync(model.CustomerId);

                _mailHelper.SendMail(customer.User.Email, "YourVet App - Appointment", $"<h1>YourVet - Appointment scheduled successfully</h1>" +
                                     $"<br/>" +
                                     $"<h4>Hello {appointment.Customer.User.FullName}, welcome to YourVet.</4>" +
                                     $"<h5>Your appointment was scheduled successfully.</h5>" +
                                     $"<br/>" +
                                     $"<p>Schedule details:</p>" +
                                     $"<p>Date and time: {appointment.AppDate}</p>" +
                                     $"<p>Doctor: {appointment.Doctor.FullName}</p>" +
                                     $"<p>Date and time: {appointment.Pet.Name}</p>" +
                                     $"<br/>" +
                                     $"<p>Please arrive 10 minutes before the scheduled time.</p>");

                await _appRepository.CreateAsync(appointment);

                return(RedirectToAction(nameof(Index)));
            }

            model.Doctors      = _combosHelper.GetComboDoctors();
            model.Customers    = _combosHelper.GetComboCustomers();
            model.Pets         = _combosHelper.GetComboPets(model.CustomerId);
            model.ServiceTypes = _combosHelper.GetComboServiceTypes();


            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task <ServiceResponeCode> CreateAsync(ApplicationParam entityToCreate)
        {
            if (entityToCreate.Id != 0)
            {
                return(ServiceResponeCode.INVALID);
            }
            try
            {
                await _appRepository.CreateAsync(entityToCreate);

                return(ServiceResponeCode.OK);
            }
            catch
            {
                return(ServiceResponeCode.ERROR);
            }
        }