public async Task <ActionResult <int> > UpdateTodoItem([FromBody] Entities.Appointment item) { try { _context.Appointments.Update(item); var result = await _context.SaveChangesAsync(); return(item.AppointmentID); } catch (Exception ex) { } return(null); }
public async Task <ActionResult <Entities.Appointment> > DeleteAppointment([FromBody] Entities.Appointment item) { try { var student = await _context.Appointments.FirstOrDefaultAsync(b => b.AppointmentID == item.AppointmentID); _context.Appointments.Remove(student); await _context.SaveChangesAsync(); return(NoContent()); } catch (Exception ex) { } return(null); }
public async Task <ActionResult <int> > CreateAppointment([FromBody] Entities.Appointment item) { try { _context.Appointments.Add(item); var result = await _context.SaveChangesAsync(); //Sending email var message = new MimeMessage(); //From Address message.From.Add(new MailboxAddress("sai vaibhav medavarapu", "*****@*****.**")); //To address message.To.Add(new MailboxAddress("Sachin Samrat Medavarapu", "*****@*****.**")); //Subject message.Subject = "Appointment confirmed"; //Body message.Body = new TextPart("plain") { Text = "Appointment confirmed" }; //Configure and send the email using (var client = new SmtpClient()) { // For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS) client.ServerCertificateValidationCallback = (s, c, h, e) => true; client.Connect("smtp.gmail.com", 587, false); // Note: only needed if the SMTP server requires authentication client.Authenticate("Sai Vaibhav Medavarapu", "flipkart1!"); client.Send(message); client.Disconnect(true); } return(item.AppointmentID); } catch (Exception ex) { } return(null); }
public async Task Should_Add_Project() { // Arrange DbSet <Entities.Appointment> mockData = MockDbSets.Appointments; Entities.Appointment appointment = AppointmentSeedData.RockingXMasConcert; mockData.FindAsync(Arg.Any <object[]>(), Arg.Any <CancellationToken>()).Returns(appointment); _arpaContext.Appointments.Returns(mockData); _arpaContext.SaveChangesAsync(Arg.Any <CancellationToken>()).Returns(1); // Act Unit result = await _handler.Handle(new AddProject.Command( appointment.Id, ProjectSeedData.HoorayForHollywood.Id), new CancellationToken()); // Assert result.Should().BeEquivalentTo(Unit.Value); }
public Models.Appointment CreateAppointment(DateTime dateTime, Guid patientId, Guid physicianId) { var vm = new Models.Appointment { Start = dateTime, End = dateTime.AddMinutes(10), Title = "Consulta con " + "Neurología", PatientId = patientId, }; //TODO: Esta responsabilidad debería ser controller para hacer el mapeo entre VM -> DM var model = new Entities.Appointment { Start = vm.Start, End = vm.End, Title = vm.Title }; _appointmentsRepository.Save(model); return(vm); }
public async Task <int> Create(Model.Appointment appointmentModel) { Entities.Appointment appointment = new Entities.Appointment(); appointment.CustomerId = appointmentModel.CustomerId; appointment.DateAdd = DateTime.Now; appointment.PickTicketId = appointmentModel.PickTicket; appointment.DivisionId = appointmentModel.DivisionId; appointment.ScacCode = appointmentModel.ScacCode; appointment.ShipDate = appointmentModel.ShippingDate.Value; appointment.ShipTime = new DateTime(appointmentModel.ShippingDate.Value.Year, appointmentModel.ShippingDate.Value.Month, appointmentModel.ShippingDate.Value.Day, appointmentModel.ShippingTime.Value.Hour, appointmentModel.ShippingTime.Value.Minute, 0); appointment.AppointmentNumber = appointmentModel.AppointmentNumber; appointment.DeliveryTypeId = appointmentModel.DeliveryTypeId.Value; appointment.UserName = appointmentModel.UserName; if (appointmentModel.ShippingTimeLimit.HasValue) { appointment.ShippingTimeLimit = new DateTime(appointmentModel.ShippingDate.Value.Year, appointmentModel.ShippingDate.Value.Month, appointmentModel.ShippingDate.Value.Day, appointmentModel.ShippingTimeLimit.Value.Hour, appointmentModel.ShippingTimeLimit.Value.Minute, 0); } appointment.PtBulk = string.Empty; if (!string.IsNullOrEmpty(appointmentModel.PtBulk)) { appointment.PtBulk = appointmentModel.PtBulk; appointment.PickTicketId = appointmentModel.PtBulk; } context.Appointments.Add(appointment); try { return(await context.SaveChangesAsync()); } catch (Exception ex) { throw ex; } }
public async Task <string> SetAppointment(Model.Appointment appointmentModel, Model.OrderAppointment order) { using (System.Data.Entity.DbContextTransaction dbTran = context.Database.BeginTransaction()) { try { var existingAppt = context.Appointments.Where(x => x.CustomerId == appointmentModel.CustomerId && x.PickTicketId == appointmentModel.PickTicket).FirstOrDefault(); if (existingAppt != null) { if (existingAppt.Status == "D") { // update the existing one, could be a previous cancelation context.Appointments.Remove(existingAppt); } else { throw new ArgumentException($"Order with picticket {appointmentModel.PickTicket} for client {appointmentModel.CustomerId} already have an appointment {existingAppt.AppointmentNumber}"); } } Entities.Appointment appointment = new Entities.Appointment(); appointment.CustomerId = appointmentModel.CustomerId; appointment.DateAdd = DateTime.Now; appointment.PickTicketId = appointmentModel.PickTicket; appointment.DivisionId = appointmentModel.DivisionId; appointment.ScacCode = appointmentModel.ScacCode; // appointment.ShipDate = appointmentModel.ShippingDate.Value; appointment.ShipTime = new DateTime(appointmentModel.ShippingDate.Value.Year, appointmentModel.ShippingDate.Value.Month, appointmentModel.ShippingDate.Value.Day, appointmentModel.ShippingTime.Value.Hour, appointmentModel.ShippingTime.Value.Minute, 0); appointment.AppointmentNumber = appointmentModel.AppointmentNumber; appointment.DeliveryTypeId = appointmentModel.DeliveryTypeId.Value; appointment.UserName = appointmentModel.UserName; appointment.Pallets = appointmentModel.Pallets; appointment.DriverId = appointmentModel.DriverId; appointment.TruckId = appointmentModel.TruckId; if (appointmentModel.ShippingTimeLimit.HasValue) { appointment.ShippingTimeLimit = new DateTime(appointmentModel.ShippingDate.Value.Year, appointmentModel.ShippingDate.Value.Month, appointmentModel.ShippingDate.Value.Day, appointmentModel.ShippingTimeLimit.Value.Hour, appointmentModel.ShippingTimeLimit.Value.Minute, 0); } appointment.PtBulk = string.Empty; if (!string.IsNullOrEmpty(appointmentModel.PtBulk)) { appointment.PtBulk = appointmentModel.PtBulk; appointment.PickTicketId = appointmentModel.PtBulk; } context.Appointments.Add(appointment); var ptBulk = string.IsNullOrEmpty(appointment.PtBulk) ? "" : appointment.PtBulk; var entity = await context.OrderAppointments.Where(x => x.PurchaseOrderId == order.PurchaseOrderId && x.PickTicketId == appointment.PickTicketId && x.CustomerId == appointment.CustomerId && x.PtBulk == ptBulk).FirstOrDefaultAsync(); if (entity != null) { entity.Status = 1; entity.ShipFor = appointmentModel.ShippingDate.Value; entity.Notes = !string.IsNullOrEmpty(entity.Notes) ? $"{entity.Notes} / {order.Notes}" : order.Notes; } await context.SaveChangesAsync(); dbTran.Commit(); return(null); } catch (Exception exc) { dbTran.Rollback(); return($"{exc.Message} : { exc.InnerException?.Message} "); } } }