// Return Details of a Certain Case
        public ActionResult CaseDetails(long caseId)
        {
            long userId;

            if (Session["USER"] != null)
            {
                userId = ((User)Session["USER"]).UserID;
            }
            else
            {
                userId = 2;
            }
            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <Case>   caseRepository   = unitOfWork.GetRepoInstance <Case>();
            GenericRepository <Status> statusRepository = unitOfWork.GetRepoInstance <Status>();
            Case userCase = caseRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault();

            userCase.Status = statusRepository.GetBy(st => st.StatusID == userCase.StatusID).FirstOrDefault();
            GenericRepository <File> fileRepository = unitOfWork.GetRepoInstance <File>();
            File userFile = fileRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault();

            DateTime End = userCase.SubmissionDate.AddDays(3);

            ViewBag.Timer = End.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;

            CaseDetailsVM caseDetailsVM = new CaseDetailsVM();

            caseDetailsVM.Case = userCase;

            if (userFile != null)
            {
                caseDetailsVM.FileID        = userFile.FileID;
                caseDetailsVM.FileName      = userFile.FileName;
                caseDetailsVM.Content       = userFile.Content;
                caseDetailsVM.SavedFileName = userFile.SavedFileName;
            }
            GenericRepository <Employee_Case> empCaseRepository = unitOfWork.GetRepoInstance <Employee_Case>();

            if (userCase.StatusID == 2)
            {
                Employee_Case empCase = empCaseRepository.GetBy(ec => ec.CaseID == caseId && ec.EmployeeID == userId).FirstOrDefault();
                if (empCase.OpenedAt == null)
                {
                    empCase.OpenedAt = DateTime.Now;
                    empCaseRepository.Edit(empCase);
                    unitOfWork.SaveChanges();
                }
            }
            if (userCase.StatusID == 2 || userCase.StatusID == 3)
            {
                Employee_Case empCase = empCaseRepository.GetBy(ec => ec.CaseID == caseId && ec.EmployeeID == userId).FirstOrDefault();
                if (empCase.OpenedAt != null)
                {
                    DateTime timer2 = (DateTime)empCase.OpenedAt;
                    ViewBag.Timer2 = timer2.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;
                }
            }

            return(View(caseDetailsVM));
        }
Exemple #2
0
        public JsonResult SaveCase(CaseDetailsVM caseDetails)
        {
            List <VictimDetails> victims = new List <VictimDetails>();
            var agentId = "Pranay";

            foreach (var item in caseDetails.VictimsDetails)
            {
                VictimDetails victim = new VictimDetails
                {
                    Name           = item.Name,
                    Age            = item.Age,
                    ChiefComplaint = item.ChiefComplaint,
                    Gender         = item.Gender,
                    Remarks        = item.Remarks,
                    VictimId       = item.VictimId
                };
                victims.Add(victim);
            }

            CaseDetails newCaseDetails = new CaseDetails
            {
                CallId               = caseDetails.CallId,
                CallerName           = caseDetails.CallerName,
                CallTime             = caseDetails.CallTime,
                CallType             = caseDetails.CallType,
                IncidentLocation     = caseDetails.IncidentLocation,
                CaseStartTime        = caseDetails.CaseStartTime,
                ContactNumber        = caseDetails.ContactNumber,
                HospitalHandOverTime = caseDetails.HospitalHandOverTime,
                BackToBaseTime       = caseDetails.BackToBaseTime,
                InstituteReachTime   = caseDetails.InstituteReachTime,
                SceneReachTime       = caseDetails.SceneReachTime,
                SceneDepartureTime   = caseDetails.SceneDepartureTime,
                StandardRemark       = caseDetails.StandardRemark,
                InstituteReachOdo    = caseDetails.InstituteReachOdo,
                BackToBaseOdo        = caseDetails.BackToBaseOdo,
                SceneReachOdo        = caseDetails.SceneReachOdo,
                StartOdo             = caseDetails.StartOdo,
                VehicleDetails       = new Vehicle
                {
                    VehicleId     = caseDetails.VehicleDetails.VehicleId,
                    VehicleNumber = caseDetails.VehicleDetails.VehicleNumber,
                    State         = caseDetails.VehicleDetails.State
                },
                VictimsDetails = victims
            };
            var status = 2;
            var result = callIncident.SaveNewCaseDetails(newCaseDetails, agentId, status);

            return(Json(new { success = true }));
        }
Exemple #3
0
        // Return Details of a Certain Case
        public ActionResult CaseDetails(long caseId)
        {
            long userId;

            if (Session["USER"] != null)
            {
                userId = ((User)Session["USER"]).UserID;
            }
            else
            {
                return(RedirectToAction("Login", "Login", new { area = "Admin" }));
            }

            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];

            GenericRepository <Case> caseRepository = unitOfWork.GetRepoInstance <Case>();
            Case userCase = caseRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault();

            GenericRepository <File> fileRepository = unitOfWork.GetRepoInstance <File>();
            File userFile = fileRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault();

            CaseDetailsVM caseDetailsVM = new CaseDetailsVM();

            caseDetailsVM.Case = userCase;

            if (userFile != null)
            {
                caseDetailsVM.FileID        = userFile.FileID;
                caseDetailsVM.FileName      = userFile.FileName;
                caseDetailsVM.Content       = userFile.Content;
                caseDetailsVM.SavedFileName = userFile.SavedFileName;
            }

            //if (userCase.StatusID == 4)
            //{
            GenericRepository <Employee> empRepository = unitOfWork.GetRepoInstance <Employee>();
            List <Employee> allEmp = empRepository.GetBy(c => c.CategoryID == userCase.CategoryID && c.RoleID == 3).ToList();

            caseDetailsVM.AllEmployees = allEmp;
            //}

            if (userCase.StatusID == 2)
            {
                GenericRepository <Employee_Case> empCaseRepo = unitOfWork.GetRepoInstance <Employee_Case>();
                Employee_Case assignedEmp = empCaseRepo.GetBy(ec => ec.CaseID == userCase.CaseID).FirstOrDefault();
                //GenericRepository<Employee> empRepository = unitOfWork.GetRepoInstance<Employee>();
                //Employee emp = empRepository.GetBy(e => e.EmployeeID == assignedEmp.EmployeeID).FirstOrDefault();
                GenericRepository <User> userRepository = unitOfWork.GetRepoInstance <User>();
                User assignedUser = userRepository.GetBy(u => u.UserID == assignedEmp.EmployeeID).FirstOrDefault();

                List <Employee_Case> allEmpCases = empCaseRepo.GetBy(ec => ec.CaseID == userCase.CaseID).ToList();
                //List<Employee> allEmp = new List<Employee>();
                List <User> allAssignedEmps = new List <User>();
                foreach (Employee_Case empc in allEmpCases)
                {
                    //Employee temp = empRepository.GetBy(e => e.EmployeeID == empc.EmployeeID).FirstOrDefault();
                    User temp2 = userRepository.GetBy(u => u.UserID == empc.EmployeeID).FirstOrDefault();
                    //allEmp.Add(temp);
                    allAssignedEmps.Add(temp2);
                }
                caseDetailsVM.AllEmployeeCases     = allEmpCases;
                caseDetailsVM.AllAssignedEmployees = allAssignedEmps;
            }

            return(View("CategoryAdminCaseDetails", caseDetailsVM));
        }
Exemple #4
0
        // Return Details of a Certain Case
        public ActionResult CaseDetails(long caseId)
        {
            long userId;

            if (Session["USER"] != null)
            {
                userId = ((User)Session["USER"]).UserID;
            }
            else
            {
                userId = 2;
            }
            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <Case>   caseRepository   = unitOfWork.GetRepoInstance <Case>();
            GenericRepository <Status> statusRepository = unitOfWork.GetRepoInstance <Status>();
            Case userCase = caseRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault();

            userCase.Status = statusRepository.GetBy(st => st.StatusID == userCase.StatusID).FirstOrDefault();
            GenericRepository <File> fileRepository = unitOfWork.GetRepoInstance <File>();
            File     userFile   = fileRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault();
            DateTime ServerTime = DateTime.Now;

            ViewBag.ServerTime = ServerTime.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;
            DateTime End = userCase.SubmissionDate.AddDays(3);

            ViewBag.Timer = End.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;

            CaseDetailsVM caseDetailsVM = new CaseDetailsVM();

            caseDetailsVM.Case = userCase;

            if (userFile != null)
            {
                caseDetailsVM.FileID        = userFile.FileID;
                caseDetailsVM.FileName      = userFile.FileName;
                caseDetailsVM.Content       = userFile.Content;
                caseDetailsVM.SavedFileName = userFile.SavedFileName;
            }
            GenericRepository <Employee_Case> empCaseRepository = unitOfWork.GetRepoInstance <Employee_Case>();

            if (userCase.StatusID == 2)
            {
                Employee_Case empCase = empCaseRepository.GetBy(ec => ec.CaseID == caseId && ec.EmployeeID == userId).FirstOrDefault();
                if (empCase.OpenedAt == null)
                {
                    empCase.OpenedAt = DateTime.Now;
                    empCaseRepository.Edit(empCase);
                    unitOfWork.SaveChanges();
                }
            }
            if (userCase.StatusID == 2 || userCase.StatusID == 3)
            {
                Employee_Case empCase = empCaseRepository.GetBy(ec => ec.CaseID == caseId && ec.EmployeeID == userId).FirstOrDefault();
                if (empCase.OpenedAt != null)
                {
                    DateTime timer2 = (DateTime)empCase.OpenedAt;
                    ViewBag.Timer2 = timer2.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;
                }
            }
            caseDetailsVM.MessagesModel          = new MessagesVM();
            caseDetailsVM.MessagesModel.Messages = new List <Message>();

            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <Message> messageRepository = unitOfWork.GetRepoInstance <Message>();

            var result = messageRepository.GetBy(m => m.CaseID == caseId && (m.ReceiverID == userId || m.SenderID == userId)).OrderByDescending(m => m.SubmissionDate);

            if (result != null)
            {
                foreach (Message message in result)
                {
                    caseDetailsVM.MessagesModel.Messages.Add(message);
                }
            }
            int page       = 1;
            int pageSize   = 3;
            int pageNumber = 1;

            caseDetailsVM.MessagesModel.Messages.ToPagedList(pageNumber, pageSize);
            return(View(caseDetailsVM));
        }
        // Return Details of a Certain Case
        public ActionResult CaseDetails(long caseId)
        {
            long userId;

            if (Session["USER"] != null)
            {
                userId = ((User)Session["USER"]).UserID;
            }
            else
            {
                return(RedirectToAction("Login", "Login", new { area = "Admin" }));
            }

            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];

            GenericRepository <Case> caseRepository = unitOfWork.GetRepoInstance <Case>();
            Case userCase = caseRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault();

            GenericRepository <File> fileRepository = unitOfWork.GetRepoInstance <File>();
            File userFile = fileRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault();

            CaseDetailsVM caseDetailsVM = new CaseDetailsVM();

            caseDetailsVM.Case = userCase;

            if (userFile != null)
            {
                caseDetailsVM.FileID        = userFile.FileID;
                caseDetailsVM.FileName      = userFile.FileName;
                caseDetailsVM.Content       = userFile.Content;
                caseDetailsVM.SavedFileName = userFile.SavedFileName;
            }

            //if (userCase.StatusID == 4)
            //{
            GenericRepository <Employee> empRepository = unitOfWork.GetRepoInstance <Employee>();
            List <Employee> allEmp = empRepository.GetBy(c => c.CategoryID == userCase.CategoryID && c.RoleID == 3).ToList();

            caseDetailsVM.AllEmployees = allEmp;
            //}

            if (userCase.StatusID != 4)
            {
                GenericRepository <Employee_Case> empCaseRepo = unitOfWork.GetRepoInstance <Employee_Case>();
                Employee_Case assignedEmp = empCaseRepo.GetBy(ec => ec.CaseID == userCase.CaseID).FirstOrDefault();
                //GenericRepository<Employee> empRepository = unitOfWork.GetRepoInstance<Employee>();
                //Employee emp = empRepository.GetBy(e => e.EmployeeID == assignedEmp.EmployeeID).FirstOrDefault();
                GenericRepository <User> userRepository = unitOfWork.GetRepoInstance <User>();
                if (userCase.StatusID == 2)
                {
                    User assignedUser = userRepository.GetBy(u => u.UserID == assignedEmp.EmployeeID).FirstOrDefault();
                }


                List <Employee_Case> allEmpCases = empCaseRepo.GetBy(ec => ec.CaseID == userCase.CaseID).ToList();
                //List<Employee> allEmp = new List<Employee>();
                List <User> allAssignedEmps = new List <User>();
                foreach (Employee_Case empc in allEmpCases)
                {
                    //Employee temp = empRepository.GetBy(e => e.EmployeeID == empc.EmployeeID).FirstOrDefault();
                    User temp2 = userRepository.GetBy(u => u.UserID == empc.EmployeeID).FirstOrDefault();
                    //allEmp.Add(temp);
                    allAssignedEmps.Add(temp2);
                }
                caseDetailsVM.AllEmployeeCases       = allEmpCases;
                caseDetailsVM.AllAssignedEmployees   = allAssignedEmps;
                caseDetailsVM.MessagesModel          = new MessagesVM();
                caseDetailsVM.MessagesModel.Messages = new List <Message>();

                unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
                GenericRepository <Message> messageRepository = unitOfWork.GetRepoInstance <Message>();

                var result = messageRepository.GetBy(m => m.CaseID == caseId).OrderByDescending(m => m.SubmissionDate);
                if (result != null)
                {
                    foreach (Message message in result)
                    {
                        caseDetailsVM.MessagesModel.Messages.Add(message);
                    }
                }
                int page       = 1;
                int pageSize   = 3;
                int pageNumber = 1;
                caseDetailsVM.MessagesModel.Messages.ToPagedList(pageNumber, pageSize);
            }

            return(View("CategoryAdminCaseDetails", caseDetailsVM));
        }
        public ActionResult CaseDetails(long caseId)
        {
            long userId;

            if (Session["USER"] != null)
            {
                userId = ((User)Session["USER"]).UserID;
            }
            else
            {
                userId = 1;
            }

            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <Case>   caseRepository   = unitOfWork.GetRepoInstance <Case>();
            GenericRepository <Status> statusRepository = unitOfWork.GetRepoInstance <Status>();
            Case userCase = caseRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault();

            userCase.Status = statusRepository.GetBy(st => st.StatusID == userCase.StatusID).FirstOrDefault();
            GenericRepository <Employee_Case> empCaseRepository = unitOfWork.GetRepoInstance <Employee_Case>();

            if (empCaseRepository.GetBy(c => c.CaseID == caseId).Count() != 0)
            {
                ViewBag.LastRating = empCaseRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault().Rating;
            }
            if (userCase.StartupID == userId)
            {
                CaseDetailsVM caseDetailsVM = new CaseDetailsVM();
                caseDetailsVM.Case                   = userCase;
                caseDetailsVM.MessagesModel          = new MessagesVM();
                caseDetailsVM.MessagesModel.Messages = new List <Message>();

                unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
                GenericRepository <Message> messageRepository = unitOfWork.GetRepoInstance <Message>();

                int page       = 1;
                int pageSize   = 2;
                int pageNumber = 1;
                int pageCount  = 1;

                var result = messageRepository.GetBy(m => m.CaseID == caseId && (m.ReceiverID == userId || m.SenderID == userId)).OrderByDescending(m => m.SubmissionDate);
                if (result != null)
                {
                    pageCount = (int)Math.Ceiling((double)result.Count() / pageSize);
                    var result2 = result.Skip((pageNumber - 1) * pageSize).Take(pageSize);
                    foreach (Message message in result2)
                    {
                        caseDetailsVM.MessagesModel.Messages.Add(message);
                    }
                }

                ViewBag.CurrentPage = pageNumber;
                ViewBag.PageCount   = pageCount;
                ViewBag.Case        = caseId;

                return(View(caseDetailsVM));
            }
            else
            {
                return(HttpNotFound());
            }
        }