示例#1
0
        // GET: Requsition/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            int requsitionId = (int)id;

            Requsition requsition = _requisitionManager.GetById(requsitionId);

            if (requsition == null)
            {
                return(HttpNotFound());
            }
            var employee = _employeeManager.Get(c => c.IsDriver == true && c.IsDeleted == false);
            var manager  = _managerManager.GetAll();
            RequsitionViewModel requsitionViewModel = new RequsitionViewModel();

            requsitionViewModel.Id           = requsition.Id;
            requsitionViewModel.Form         = requsition.Form;
            requsitionViewModel.To           = requsition.To;
            requsitionViewModel.JourneyStart = requsition.JourneyStart;
            requsitionViewModel.JouneyEnd    = requsition.JouneyEnd;
            requsitionViewModel.Description  = requsition.Description;
            requsitionViewModel.Employee     = requsition.Employee;
            requsitionViewModel.Manager      = manager.FirstOrDefault(c => c.RequsitionId == requsition.Id);

            int?   emplId      = requsition.EmployeeId;
            string employeeNam = requsition.Employee.Name;

            requsitionViewModel.CommentViewModel = new CommentViewModel
            {
                EmployeeId   = (int)emplId,
                EmployeName  = employeeNam,
                RequsitionId = requsitionId
            };

            //Collect the list of comment to display the list under comment
            List <CommentViewModel> commentListViewModel = new List <CommentViewModel>();
            var commentListView = commentManager.GetCommentsByRequisition(requsitionId);

            foreach (var item in commentListView.ToList())
            {
                commentListViewModel.Add
                (
                    new CommentViewModel
                {
                    RequsitionId = requsitionId,
                    Comments     = item.Comments,
                    EmployeeId   = item.EmployeeId,
                    EmployeName  = item.Employee.Name,
                    UserName     = item.UserName,
                    CommentTime  = item.CommentTime
                }
                );
            }
            requsitionViewModel.CommentViewModels = commentListViewModel;

            return(View(requsitionViewModel));
        }
示例#2
0
        private void GetCommentList(Requsition requisition, AssignedListViewModel assignVm)
        {
            List <CommentViewModel> commentListViewModel = new List <CommentViewModel>();
            var commentListView = commentManager.GetCommentsByRequisition(requisition.Id);

            foreach (var item in commentListView.ToList())
            {
                var cmnt = new CommentViewModel
                {
                    Id                 = item.Id,
                    RequsitionId       = item.RequsitionId,
                    EmployeeId         = item.EmployeeId,
                    Comments           = item.Comments,
                    UserName           = item.UserName,
                    CommentTime        = item.CommentTime,
                    IsReceiverSeen     = item.IsReceiverSeen,
                    ReceiverSeenTime   = item.ReceiverSeenTime,
                    SenderEmployee     = item.SenderEmployee,
                    SenderEmployeeId   = (int)item.SenderEmployeeId,
                    ReceiverEmployee   = item.ReceiverEmployee,
                    ReceiverEmployeeId = (int)item.ReceiverEmployeeId,
                };


                commentListViewModel.Add(cmnt);
            }
            assignVm.CommentViewModels = commentListViewModel;
        }