public ActionResult AcceptLeave(int id = 1) { Leave l = dal.GetLeave(id); Collaborator coll = dal.GetCollaborator(System.Web.HttpContext.Current.User.Identity.Name); if (l.Status == LeaveStatus.PENDING_APPROVAL_1) { foreach (Collaborator c in dal.GetCollaborators()) { if (c.Role != Roles.CHIEF && c.Service.Name.Contains("RH")) { dal.AddNotification(new Notification(l.Collaborator, c, NotificationType.LEAVE)); } } l.Status = LeaveStatus.PENDING_APPROVAL_2; //send a notification dal.AddNotification(new Notification(coll, l.Collaborator, NotificationType.LEAVE, NotificationResult.VALIDATION)); } else { l.Status = LeaveStatus.APPROVED; //switch(l.Type) //{ // case LeaveType.PAID: // l.Collaborator.NbPaid -= l.ComputeLengthLeave(); // break; // case LeaveType.RTT: // l.Collaborator.NbRTT -= l.ComputeLengthLeave(); // break; //} //send a notification dal.AddNotification(new Notification(coll, l.Collaborator, NotificationType.LEAVE, NotificationResult.VALIDATION)); } dal.SaveChanges(); return(Redirect("/Leave/ProcessList")); }