public static List <TaskDTO> GetAllTasks() { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { List <getAllTasks_Result> tasks = (from t in db.getAllTasks() select t).OrderBy(t => t.ClassificationID).OrderBy(t => t.DateForHandling).ToList(); return(ConvertListToDTO(tasks)); } }
public static bool UpdateRental(RentalDTO rd) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { Rental r = db.Rentals.Find(rd.RentalID); r.PropertyID = rd.PropertyID; r.SubPropertyID = rd.SubPropertyID; r.UserID = rd.UserID; r.RentPayment = rd.RentPayment; r.PaymentTypeID = rd.PaymentTypeID; r.EnteryDate = rd.EnteryDate; r.EndDate = rd.EndDate; if (r.ContactRenew != rd.ContactRenew) { if (rd.ContactRenew == true && rd.EndDate.Value < DateTime.Today.AddMonths(3)) { Bl.TaskBL.AddRenewTask(rd.PropertyID, rd.SubPropertyID); } else { getAllTasks_Result task = db.getAllTasks().Where(t => t.PropertyID == rd.PropertyID && t.TaskTypeId == 2 && t.status == true && t.SubPropertyID == rd.SubPropertyID).FirstOrDefault(); if (task != null) { Bl.TaskBL.DeleteTask(task.TaskID); } } } r.ContactRenew = rd.ContactRenew; if (rd.Dock != null) { Document doc = new Document(); doc.DocCoding = rd.Dock; doc.DocUser = rd.RentalID; doc.type = 3; doc.DocName = rd.DocName; DocumentBL.AddUserDocuments(new DocumentDTO(doc)); } db.SaveChanges(); return(true); } return(false); }