public ActionResult Filter(BoardNotification data) { Api API = new Api(); Dictionary <string, string> arg = new Dictionary <string, string>() { { "TypeNotificationId", data.TypeNotificationId.ToString() }, { "OrganizationId", data.OrganizationId }, { "Worker", data.Worker }, { "StateNotificationId", data.StateNotificationId.ToString() }, { "NotificationDateStart", data.NotificationDateStart }, { "NotificationDateEnd", data.NotificationDateEnd }, { "Title", data.Title }, { "Index", data.Index.ToString() }, { "Take", data.Take.ToString() } }; Dictionary <string, string> arg2 = new Dictionary <string, string>() { { "grupoId", ((int)Enums.SystemParameter.NotificationType).ToString() }, }; ViewBag.NotificationType = Utils.Utils.LoadDropDownList(API.Get <List <Dropdownlist> >("SystemParameter/GetParametroByGrupoId", arg2), Constants.Select); ViewBag.Notifications = API.Post <BoardNotification>("Notification/FilterNotifications", arg); return(PartialView("_BoardMailBodyPartial")); }
public List <ShortBoardDTO> GetBoardsByUser(string username) { List <ShortBoardDTO> dtos = new List <ShortBoardDTO>(); using (UnitOfWork unit = new UnitOfWork()) { User user = unit.UserRepository.GetUserByUsername(username); if (user != null) { foreach (var p in user.Permissions) { if (p != null && p.Board != null) { BoardNotification notif = unit.BoardNotificationRepository .GetBoardNotification(p.Board.BoardId, user.UserId); if (notif != null) { dtos.Add(new ShortBoardDTO(p.Board, notif.IsRead)); } else { dtos.Add(new ShortBoardDTO(p.Board, true)); } } } } } return(dtos); }
public BoardNotification FilterNotifications(BoardNotification data) { using (var dbContext = new DatabaseContext()) { int skip = (data.Index - 1) * data.Take; string filterPacient = string.IsNullOrWhiteSpace(data.Worker) ? "" : data.Worker; var dateStart = DateTime.Parse(data.NotificationDateStart); var dateEnd = DateTime.Parse(data.NotificationDateEnd).AddDays(1); var title = data.Title == null ? "" : data.Title; var query = (from a in dbContext.Notification join b in dbContext.SystemParameter on new { a = a.i_TypeNotificationId.Value, b = 347 } equals new { a = b.i_ParameterId, b = b.i_GroupId } join c in dbContext.SystemUser on a.i_InsertUserId equals c.i_SystemUserId join d in dbContext.Person on c.v_PersonId equals d.v_PersonId join e in dbContext.Organization on a.v_OrganizationId equals e.v_OrganizationId join f in dbContext.Person on a.v_PersonId equals f.v_PersonId join g in dbContext.SystemParameter on new { a = a.i_IsRead.Value, b = 111 } equals new { a = g.i_ParameterId, b = g.i_GroupId } join h in dbContext.SystemParameter on new { a = a.i_StateNotificationId.Value, b = 348 } equals new { a = h.i_ParameterId, b = h.i_GroupId } where (data.TypeNotificationId == -1 || a.i_TypeNotificationId == data.TypeNotificationId) && ((f.v_FirstName + " " + f.v_FirstLastName + " " + f.v_SecondLastName).Contains(filterPacient) || f.v_DocNumber.Contains(filterPacient)) && (data.OrganizationId == "-1" || a.v_OrganizationId == data.OrganizationId) && (a.d_NotificationDate >= dateStart && a.d_NotificationDate <= dateEnd) && (a.v_Title.Contains(title)) && (data.StateNotificationId == -1 || a.i_StateNotificationId == data.StateNotificationId) select new NotificationsBE { PersonId = a.v_PersonId, NotificationId = a.v_NotificationId, Organization = e.v_Name, NotificationDate = a.d_NotificationDate, TypeNotificationId = a.i_TypeNotificationId, TypeNotification = b.v_Value1, Title = a.v_Title, Body = a.v_Body, SystemUserId = a.i_InsertUserId, SystemUser = d.v_FirstName + " " + d.v_FirstLastName, IsRead = a.i_IsRead, Read = g.v_Value1, Worker = f.v_FirstName + " " + f.v_FirstLastName + " " + f.v_SecondLastName, StateNotification = h.v_Value1 }).ToList(); data.TotalRecords = query.Count; if (data.Take > 0) { query = query.Skip(skip).Take(data.Take).ToList(); } data.list = query; return(data); } }
public ReadUserDTO AddUserBoardPermision(AddUserBoardPermisionDTO dto, string admin) { bool ret = false; using (UnitOfWork unit = new UnitOfWork()) { bool isAdmin = unit.PermissionRepository.IsAdmin(dto.BoardId, admin); Permission perm = unit.PermissionRepository.GetPermissionByUsername(dto.BoardId, dto.Username); if (isAdmin && perm == null) { Board b = unit.BoardRepository.GetById(dto.BoardId); User u = unit.UserRepository.GetUserByUsername(dto.Username); if (u != null && b != null) { Permission p = new Permission() { Board = b, User = u }; BoardNotification boardNotification = new BoardNotification() { Board = b, User = u }; unit.PermissionRepository.Insert(p); unit.BoardNotificationRepository.Insert(boardNotification); ret = unit.Save(); if (ret) { RabbitMQService.PublishToExchange(u.ExchangeName, new MessageContext(new BoardMessageStrategy(new BasicBoardDTO(b), MessageType.Create, admin))); RabbitMQService.PublishToExchange(b.ExchangeName, new MessageContext(new PermissionMessageStrategy(new ReadUserDTO(u), MessageType.Create, admin))); return(new ReadUserDTO(u)); } } } } return(null); }
public bool ReadBoard(int boardId, string username) { bool succ = false; using (UnitOfWork unit = new UnitOfWork()) { BoardNotification notif = unit.BoardNotificationRepository .GetBoardNotification(boardId, username); if (notif != null) { notif.IsRead = true; unit.BoardNotificationRepository.Update(notif); succ = unit.Save(); } } return(succ); }
//Ako ne uspe dodavanje board-a vratice se null public ShortBoardDTO InsertBoard(CreateBoardDTO boardDTO, string username) { Board board = boardDTO.FromDTO(); board.ExchangeName = Guid.NewGuid().ToString(); ShortBoardDTO dto = null; using (UnitOfWork unit = new UnitOfWork()) { User creator = unit.UserRepository.GetUserByUsername(username); if (board != null && creator != null) { Permission permision = new Permission() { IsAdmin = true, Board = board, User = creator }; BoardNotification boardNotif = new BoardNotification() { Board = board, User = creator }; unit.PermissionRepository.Insert(permision); unit.BoardNotificationRepository.Insert(boardNotif); if (unit.Save()) { dto = new ShortBoardDTO(board, true); RabbitMQService.DeclareExchange(board.ExchangeName); } } } return(dto); }
public BoardNotification FilterNotifications(BoardNotification data) { return(new NotificationDal().FilterNotifications(data)); }
public IHttpActionResult FilterNotifications(BoardNotification data) { var result = oNotificationBl.FilterNotifications(data); return(Ok(result)); }