public CaptureDTO Save(CaptureDTO dto) { CaptureDAO b = new CaptureDAO(); dto = b.Save(dto); string message = dto.Message; CaptureDTO capt = new CaptureDTO(); capt = b.GetCaptureById(dto.Id); if (capt == null) { capt = new CaptureDTO(); } capt.Message = message; return(capt); }
public string EditStatus(int idStatus, int idCapture, int idUserType) { CaptureDAO capDao = new CaptureDAO(); List <SkUserTypeDTOcs> listLevel = new List <SkUserTypeDTOcs>(); SoupKitchenDAO skDao = new SoupKitchenDAO(); int IdUserType = 0; var capture = capDao.GetCaptureById(idCapture); //get list of SK levels listLevel = skDao.GetUserTypeBySKId((int)capture.SoupKitchen.Id); if (listLevel.Count == 0 || listLevel == null) { IdUserType = 2; } else { if (idUserType == 1) { listLevel = listLevel.Where(f => f.UserTypeDto.ApprovalOrder > 0).ToList(); var topApproval = listLevel.OrderBy(i => i.UserTypeDto.ApprovalOrder).Take(1); IdUserType = topApproval.FirstOrDefault().UserTypeDto.Id; } else if (idUserType == 2) { IdUserType = 2; } else { IdUserType = idUserType; } } return(capDao.EditStatus(idStatus, idCapture, IdUserType)); }
public string SaveApproval(CaptureApprovalDTO dto) { string msg = string.Empty; int approvalStatus = 0; int level = 0; SoupKitchenDAO skDao = new SoupKitchenDAO(); CaptureDAO capDao = new CaptureDAO(); List <SkUserTypeDTOcs> listLevel = new List <SkUserTypeDTOcs>(); //get current level of captura approval var capture = capDao.GetCaptureById(dto.Id_Capture); //get list of SK levels listLevel = skDao.GetUserTypeBySKId((int)capture.SoupKitchen.Id); //get top level approval var topApproval = listLevel.OrderByDescending(i => i.UserTypeDto.ApprovalOrder).Take(1); //validations if (dto.UserDto.Id_User_Type != 2) { if (listLevel.Count() == 0 || listLevel == null) { msg = "El comedor no tiene niveles de aprobación asignados."; return(msg); } //1. level of user in session is a part of levels of sk listLevel.Where(i => i.Id_UserType == dto.UserDto.Id_User_Type).ToList(); if (listLevel.Count() == 0 || listLevel == null) { msg = "Su usuario no tiene el nivel de aprobación permitido para este comedor."; return(msg); } //validate if userType is equals to current level else if (dto.UserDto.Id_User_Type != capture.Id_LevelApproval) { msg = "La captura se encuentra asignada para aprobación del nivel: " + capture.UserTypeDto.Description; return(msg); } } if (dto.UserDto.Id_User_Type == 2) { //2. admin set status in approve by default, if not verify user level and appply status if (dto.Id_Status == 4) { approvalStatus = 4; dto.Id_Status = 4; level = 2; } else { approvalStatus = 5; dto.Id_Status = 6; //return to kitchen top level level = topApproval.FirstOrDefault().Id_UserType; } } else { //3. if level of user is top of sk set in approved, if not set in process of approval if (dto.Id_Status == 4) { if (dto.UserDto.Id_User_Type == topApproval.FirstOrDefault().Id_UserType) { approvalStatus = 4; dto.Id_Status = 4; level = dto.UserDto.Id_User_Type; } else { approvalStatus = 4; dto.Id_Status = 6; level = dto.UserDto.Id_User_Type + 1; } } else { approvalStatus = 5; dto.Id_Status = 6; if ((dto.UserDto.Id_User_Type - 1) > 2) { level = dto.UserDto.Id_User_Type - 1; } else { level = dto.UserDto.Id_User_Type; } } } CaptureApprovalDAO dao = new CaptureApprovalDAO(); //take dto.Id_Status return(dao.Save(dto, approvalStatus, level)); }
public void Activate(int id) { CaptureDAO c = new CaptureDAO(); c.Activate(id); }
public bool Update(CaptureDTO dto) { CaptureDAO b = new CaptureDAO(); return(b.Update(dto)); }
public void Deactivate(int id) { CaptureDAO c = new CaptureDAO(); c.Deactivate(id); }
public CaptureDTO GetCaptureById(int id) { CaptureDAO c = new CaptureDAO(); return(c.GetCaptureById(id)); }
public List <CaptureDTO> GetCapturesSearch(int userTypeId, int userId, int pState, int pSoupK, int pStatus) { CaptureDAO b = new CaptureDAO(); return(b.GetCapturesSearch(userTypeId, userId, pState, pSoupK, pStatus)); }
public List <CaptureDTO> GetCaptures(int userTypeId, int userId) { CaptureDAO b = new CaptureDAO(); return(b.GetCaptures(userTypeId, userId)); }
public List <CaptureDTO> GetCaptures() { CaptureDAO b = new CaptureDAO(); return(b.GetCaptures()); }