public ActionResult GetCurrentNotices()
        {
            ActionResult  retVal       = null;
            INoticeFacade noticeFacade = (INoticeFacade)FacadeFactory.Instance.Create(FacadeType.NoticeManagerFacade);
            OperationResult <IList <INoticeDTO> > result = noticeFacade.GetCurrentNotices();

            IList <NoticeModel> noticeModelList = null;

            if (result.IsValid())
            {
                noticeModelList = new List <NoticeModel>();
                NoticeModel noticeModel = null;
                foreach (INoticeDTO noticeDTO in result.Data)
                {
                    noticeModel = new NoticeModel();
                    DTOConverter.FillViewModelFromDTO(noticeModel, noticeDTO);
                    noticeModel.NotifierEmployeeName = noticeDTO.PostedByEmployee.FirstName + " " + noticeDTO.PostedByEmployee.LastName;
                    noticeModelList.Add(noticeModel);
                }
                retVal = View("~/Views/Notice/GetNotices.cshtml", noticeModelList);
            }
            else if (result.HasFailed())
            {
                retVal = RedirectToAction("Index", "Notice");
            }
            else
            {
                retVal = View("~/Views/Shared/Error.cshtml");
            }
            return(retVal);
        }
        public ActionResult CreateNotice(NoticeModel notice)
        {
            ActionResult retVal = null;

            if (ModelState.IsValid)
            {
                notice.PostedBy = SessionStateManager <UserInfo> .Data.Employee.EmployeeId;
                INoticeDTO noticeDTO = (INoticeDTO)DTOFactory.Instance.Create(DTOType.NoticeDTO);
                DTOConverter.FillDTOFromViewModel(noticeDTO, notice);

                INoticeFacade noticeFacade          = (INoticeFacade)FacadeFactory.Instance.Create(FacadeType.NoticeManagerFacade);
                OperationResult <INoticeDTO> result = noticeFacade.CreateNotice(noticeDTO);

                if (result.IsValid())
                {
                    retVal = new JsonResult()
                    {
                        Data = new
                        {
                            Message     = "Notice created Successfully",
                            Success     = true,
                            RedirectUrl = Url.Action("GetActiveNotices", "Notice")
                        },
                        JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    };
                }
                else if (result.HasValidationFailed() && (result.ValidationResult != null))
                {
                    foreach (EmployeePortalValidationFailure error in result.ValidationResult.Errors)
                    {
                        ModelState.AddModelError(error.PropertyName, error.ErrorMessage);
                    }

                    retVal = PartialView("~/Views/Notice/_EditNotice.cshtml", notice);
                    //retVal = PartialView("~/Views/Shared/_CreateNotice.cshtml",notice);
                }
                else if (result.HasFailed())
                {
                    //retVal = RedirectToAction("GetActiveNotices", "Notice");
                    retVal = new JsonResult()
                    {
                        Data = new
                        {
                            Message     = "Notice Creation failed",
                            Success     = false,
                            RedirectUrl = Url.Action("GetActiceNotices")
                        },
                        JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    };
                }
                else
                {
                    retVal = View("~/Views/Shared/Error.cshtml");
                }
            }
            return(retVal);
        }
Exemplo n.º 3
0
        static void GetCurrentNotices()
        {
            INoticeFacade noticeFacade = (INoticeFacade)FacadeFactory.Instance.Create(FacadeType.NoticeManagerFacade);
            OperationResult <IList <INoticeDTO> > getNoticesRetValue = noticeFacade.GetCurrentNotices();

            if (getNoticesRetValue.IsValid())
            {
                foreach (var notice in getNoticesRetValue.Data)
                {
                    System.Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", notice.NoticeId, notice.Title, notice.Description, notice.PostedBy, notice.StartDate, notice.ExpirationDate);
                }
            }
        }
Exemplo n.º 4
0
        static void DeleteNotice()
        {
            int noticeId;

            System.Console.WriteLine("Notice Id : ");
            int.TryParse(System.Console.ReadLine(), out noticeId);
            INoticeFacade          noticeFacade          = (INoticeFacade)FacadeFactory.Instance.Create(FacadeType.NoticeManagerFacade);
            OperationResult <bool> deleteNoticesRetValue = noticeFacade.DeleteNotice(noticeId);

            if (deleteNoticesRetValue.IsValid())
            {
                System.Console.WriteLine("Notice Deleted!!");
            }
            else
            {
                System.Console.WriteLine("Notice Not Deleted");
            }
        }
Exemplo n.º 5
0
        static void UpdateNotice()
        {
            INoticeDTO noticeDTO = (INoticeDTO)DTOFactory.Instance.Create(DTOType.NoticeDTO);

            int noticeId;

            System.Console.WriteLine("Notice Id : ");
            int.TryParse(System.Console.ReadLine(), out noticeId);
            noticeDTO.NoticeId = noticeId;

            System.Console.WriteLine("Title : ");
            noticeDTO.Title = System.Console.ReadLine();

            System.Console.WriteLine("Description : ");
            noticeDTO.Description = System.Console.ReadLine();

            System.Console.WriteLine("Posted By : ");
            int postedBy;

            int.TryParse(System.Console.ReadLine(), out postedBy);
            noticeDTO.PostedBy = postedBy;

            System.Console.WriteLine("Start Date : ");
            DateTime startDate;

            DateTime.TryParse(System.Console.ReadLine(), out startDate);
            noticeDTO.StartDate = startDate;

            System.Console.WriteLine("Expiration Date : ");
            DateTime expirationDate;

            DateTime.TryParse(System.Console.ReadLine(), out expirationDate);
            noticeDTO.ExpirationDate = expirationDate;

            INoticeFacade noticeFacade = (INoticeFacade)FacadeFactory.Instance.Create(FacadeType.NoticeManagerFacade);
            OperationResult <INoticeDTO> updateNoticesRetValue = noticeFacade.UpdateNotice(noticeDTO);

            if (updateNoticesRetValue.IsValid())
            {
                System.Console.WriteLine("Notice updated!!  Id  : ");
            }
        }
        public ActionResult DeleteNotice(int noticeId)
        {
            ActionResult           retVal       = null;
            INoticeFacade          noticeFacade = (INoticeFacade)FacadeFactory.Instance.Create(FacadeType.NoticeManagerFacade);
            OperationResult <bool> result       = noticeFacade.DeleteNotice(noticeId);

            if (result.IsValid())
            {
                //retVal = RedirectToAction("GetActiveNotices", "Notice");
                retVal = new JsonResult
                {
                    Data = new
                    {
                        Message = "Notice deletely successfully",
                        Success = true
                    },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
            }
            else if (result.HasFailed())
            {
                //retVal = RedirectToAction("GetActiveNotices", "Notice");
                retVal = new JsonResult
                {
                    Data = new
                    {
                        Message = "Notice could not be deleted",
                        Success = false
                    },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
            }
            else
            {
                retVal = View("~/Views/Shared/Error.cshtml");
            }
            return(retVal);
        }
        public ActionResult NoticeDetails(int noticeId)
        {
            ActionResult  retVal                = null;
            INoticeFacade noticeFacade          = (INoticeFacade)FacadeFactory.Instance.Create(FacadeType.NoticeManagerFacade);
            OperationResult <INoticeDTO> result = noticeFacade.GetNotice(noticeId);

            if (result.IsValid())
            {
                NoticeModel notice = new NoticeModel();
                DTOConverter.FillViewModelFromDTO(notice, result.Data);
                notice.NotifierEmployeeName = result.Data.PostedByEmployee.FirstName + " " + result.Data.PostedByEmployee.LastName;
                retVal = PartialView("~/Views/Notice/_NoticeDetails.cshtml", notice);
            }
            else if (result.HasFailed())
            {
                retVal = RedirectToAction("GetActiveNotices", "Notice");
            }
            else
            {
                retVal = View("~/Views/Shared/Error.cshtml");
            }
            return(retVal);
        }
        public ActionResult EditNotice(int noticeId)
        {
            ActionResult  retVal                = null;
            INoticeFacade noticeFacade          = (INoticeFacade)FacadeFactory.Instance.Create(FacadeType.NoticeManagerFacade);
            OperationResult <INoticeDTO> result = noticeFacade.GetNotice(noticeId);

            if (result.IsValid())
            {
                NoticeModel notice = new NoticeModel();
                DTOConverter.FillViewModelFromDTO(notice, result.Data);
                ViewBag.Create = false;
                retVal         = PartialView("~/Views/Notice/_EditNotice.cshtml", notice);
            }
            else if (result.HasFailed())
            {
                retVal = RedirectToAction("GetActiveNotices", "Notice");
            }
            else
            {
                retVal = View("~/Views/Shared/Error.cshtml");
            }
            return(retVal);
        }