public async Task <ActionResult> DetailOrder(ViewModels.UpdateTransaction data) { var order = await db.Orders.Include("User").Where(x => x.Id == data.Id).SingleOrDefaultAsync(); if (order != null) { order.Status = data.Status; db.Entry(order).State = EntityState.Modified; var result = await db.SaveChangesAsync(); if (result > 0) { if (data.Status == Models.OrderStatus.Approved) { await SendOrderApproveEmail(order.User); } else if (data.Status == Models.OrderStatus.Rejected) { await SendOrderRejectEmail(order.User); } else if (data.Status == Models.OrderStatus.Delivered) { await SendOrderDeliveredEmail(order.User); } return(RedirectToAction("DetailOrder", new { id = data.Id })); } } return(View("Error")); }
public async Task <ActionResult> DetailVolunteer(ViewModels.UpdateTransaction data) { var volunteer = await db.JobTransactions.Include("Job").Include("Volunteer").Where(x => x.IdTransaction == data.IdTransaction).SingleOrDefaultAsync(); if (volunteer != null) { volunteer.Status = data.Status; db.Entry(volunteer).State = EntityState.Modified; var result = await db.SaveChangesAsync(); if (result > 0) { if (data.Status == Models.RegistrationStatus.Approved) { await SendProgramRegistrationEmail(volunteer.Job, volunteer.Volunteer); } return(RedirectToAction("VolunteerJobs", new { id = volunteer.Job.Id })); } } return(View("Error")); }