Example #1
0
        public TravelDetailModel AddTravelDetail(TravelDetailModel travelDetailData)
        {
            TravelDetail travelDetail = AutoMapper.Mapper.Map <TravelDetailModel, TravelDetail>(travelDetailData);

            travelDetail.TravelDetailTrails.Add(new TravelDetailTrail()
            {
                TravelId    = travelDetail.Id,
                StatusId    = 1,
                ProcessedBy = travelDetail.UserID,
                Date        = travelDetail.Summary_SubmittedDate,
            });

            //foreach (var travelPlace in travelDetailData.TravelPlaceDetail)
            //{
            //    travelDetail.TravelPlaceDetails.Add(new Database.DAL.TravelPlaceDetail()
            //    {
            //        Id = travelDetail.Id,
            //        StateId = travelDetailData.Detail_ReturningToState,
            //        CityId = travelDetailData.Detail_ReturningToCity,
            //        Type="TravellingFrom"
            //    });
            //}

            TravelDetail traveldata = TravelRepository.AddTravelDetail(travelDetail);

            return(AutoMapper.Mapper.Map <TravelDetail, TravelDetailModel>(traveldata));
        }
Example #2
0
        public ActionResult TimeLine(int TravelID)
        {
            TravelDetailViewModel objDetailVM = new TravelDetailViewModel();

            objDetailVM.traveldetail = new TravelDetailModel();

            TravelDetailModel TravelData = objmanageTravel.GetTravelDetail(TravelID);

            return(PartialView("_TimeLine", TravelData));
        }
Example #3
0
        public ActionResult TravelList(TravelDetailViewModel objTravelDetailVM)
        {
            TravelDetailModel TravelData = objmanageTravel.GetTravelDetail(objTravelDetailVM.id);

            if (objTravelDetailVM.laststepid == TravelData.LastStatus)
            {
                var user = CurrentUserDetail();
                objTravelDetailVM.UserID = user.ID;
                objTravelDetailVM.RoleId = user.RoleId;
                objmanageTravel.UpdateTravelDetailForProcCheck(objTravelDetailVM);

                string msgRejectedBy = "";


                if (objTravelDetailVM.RoleId == (int)UserRoleEnum.ProjectManager && objTravelDetailVM.LastStatus == (int)TravelRequestStatusEnum.RejectedByProjectManager)
                {
                    SendEmailonAction(objTravelDetailVM.id, "Travel Request Rejected", "Your travel request has been rejected by " + EnumHelper <TravelRequestStatusEnum> .GetDisplayValue((TravelRequestStatusEnum.RejectedByProjectManager)).ToString());
                }
                else if (objTravelDetailVM.RoleId == (int)UserRoleEnum.Client1 && objTravelDetailVM.LastStatus == (int)TravelRequestStatusEnum.RejectedByClient1)
                {
                    msgRejectedBy = EnumHelper <TravelRequestStatusEnum> .GetDisplayValue((TravelRequestStatusEnum.RejectedByClient1)).ToString();

                    SendEmailonAction(objTravelDetailVM.id, "Travel Request Rejected", "Your travel request has been " + EnumHelper <TravelRequestStatusEnum> .GetDisplayValue((TravelRequestStatusEnum.RejectedByClient1)).ToString(), (int)UserRoleEnum.ProjectManager, msgRejectedBy);
                }
                else if (objTravelDetailVM.RoleId == (int)UserRoleEnum.Client2 && objTravelDetailVM.LastStatus == (int)TravelRequestStatusEnum.RejectedByClient2)
                {
                    msgRejectedBy = EnumHelper <TravelRequestStatusEnum> .GetDisplayValue((TravelRequestStatusEnum.RejectedByClient2)).ToString();

                    SendEmailonAction(objTravelDetailVM.id, "Travel Request Rejected", "Your travel request has been " + msgRejectedBy, (int)UserRoleEnum.ProjectManager, msgRejectedBy);
                }
                else if (objTravelDetailVM.RoleId == (int)UserRoleEnum.Client2 && objTravelDetailVM.LastStatus == (int)TravelRequestStatusEnum.ApprovedByClient2)
                {
                    SendEmailonAction(objTravelDetailVM.id, "Travel Request Approved", "Your travel request has been " + EnumHelper <TravelRequestStatusEnum> .GetDisplayValue((TravelRequestStatusEnum.ApprovedByClient2)).ToString());
                }
            }
            else
            {
                try
                {
                    TempData.Add("TravelRequest", "Travel request is already proceeding");
                }
                catch
                {
                    TempData["TravelRequest"] = "Travel request is already proceeding";
                }
            }
            return(RedirectToAction("travellist"));
        }
Example #4
0
        public ActionResult AddTravelForm(TravelDetailViewModel travelDataVm, string start_date, string end_date)
        {
            TravelDetailModel travelData = travelDataVm.traveldetail;

            travelData.UserID = CurrentUserDetail().ID;

            try
            {
                //travelDataVm.traveldetail.Detail_DepartingDate = DateTime.ParseExact(start_date, "MM/dd/yyyy", null);
                //travelDataVm.traveldetail.Detail_ReturningDate = DateTime.ParseExact(end_date, "MM/dd/yyyy", null);
                travelData.Detail_DepartingDate  = DateTimeHandling.SetDateTime(travelData.Detail_DepartingDate);
                travelData.Detail_ReturningDate  = DateTimeHandling.SetDateTime(travelData.Detail_ReturningDate);
                travelData.Summary_SubmittedDate = DateTimeHandling.SetDateTime(DateTime.Now);
                travelData.LastStatus            = Convert.ToInt32(TravelRequestStatusEnum.SubmittedByUser);;
                if (travelData.Id != 0)
                {
                    travelData.LastStatus = Convert.ToInt32(TravelRequestStatusEnum.Resubmitted);
                    //travelDataVm.id= travelData.Id;
                    objmanageTravel.UpdateTravelDetail(travelDataVm);
                }
                else
                {
                    TravelDetailModel traveldata = objmanageTravel.InsertTraveldata(travelData);
                }
                if (travelData != null)
                {
                    try
                    {
                        TempData.Add("TravelResult", "Travel Information Saved successfully");
                    }
                    catch
                    {
                        TempData["TravelResult"] = "Travel Information Saved successfully";
                    }
                    return(RedirectToAction("travellist"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(RedirectToAction("addtravelform"));
        }
Example #5
0
        public ActionResult GetCheckDate(string startdate, string enddate)
        {
            TravelDetailModel travelData = new TravelDetailModel();
            //DateTime startdate1 = DateTime.ParseExact(startdate, "MM/dd/yyyy", null);
            //DateTime enddate1 = DateTime.ParseExact(enddate, "MM/dd/yyyy", null);
            DateTime startdate1 = Convert.ToDateTime(startdate);
            DateTime enddate1   = Convert.ToDateTime(enddate);

            travelData.UserID = CurrentUserDetail().ID;
            IEnumerable <TravelDetailModel> traveldetaildata = objmanageTravel.GetTravelDetailByUserId(travelData.UserID);

            //IEnumerable<TravelDetailModel> travel = traveldetaildata.Where(e => e.Detail_DepartingDate.Date >= startdate1 && e.Detail_ReturningDate.Date <= enddate1).ToList();
            if (traveldetaildata.Count() > 0)
            {
                foreach (var item in traveldetaildata)
                {
                    DateTime dbStartTime = item.Detail_DepartingDate;
                    DateTime dbendTime   = item.Detail_ReturningDate;
                    DateTime startTime   = startdate1;
                    DateTime endTime     = enddate1;

                    if (startTime <= dbStartTime && endTime >= dbendTime)
                    {
                        return(Json("false", JsonRequestBehavior.AllowGet));
                    }
                    else if ((startTime > dbStartTime) && (startTime < dbendTime))
                    {
                        return(Json("false", JsonRequestBehavior.AllowGet));
                    }
                    else if ((endTime > dbStartTime) && (endTime < dbendTime))
                    {
                        return(Json("false", JsonRequestBehavior.AllowGet));
                    }
                }
            }
            return(Json("true", JsonRequestBehavior.AllowGet));
        }
Example #6
0
        public void UpdateTravelDetail(TravelDetailModel traveldetail)
        {
            TravelDetail traveldata = AutoMapper.Mapper.Map <TravelDetailModel, TravelDetail>(traveldetail);

            TravelRepository.UpdateTravelDetail(traveldata);
        }
Example #7
0
        public void DeleteTravelDetail(TravelDetailModel TravelDetail)
        {
            var Traveldata = AutoMapper.Mapper.Map <TravelDetailModel, TravelDetail>(TravelDetail);

            TravelRepository.DeleteTravelDetail(Traveldata);
        }
        public void UpdateTravelDetailForProcCheck(TravelDetailViewModel objTravelDetailVM)
        {
            var travelDetail      = new TravelDetailModel();
            var travelDetailTrail = new TravelDetailTrailModel();

            travelDetail = _travelRepository.GetTravelDetail(objTravelDetailVM.id);

            if (objTravelDetailVM.RoleId == (int)UserRoleEnum.ProjectManager)
            {
                if (objTravelDetailVM.LastStatus == (int)TravelRequestStatusEnum.RejectedByProjectManager)
                {
                    travelDetail.IsProcedural = (int)ProcedureEnum.Default;
                }
                else if (objTravelDetailVM.LastStatus == (int)TravelRequestStatusEnum.ApprovedByProjectManager)
                {
                    if (objTravelDetailVM.IsProcedural == (int)ProcedureEnum.Procedural)
                    {
                        travelDetailTrail.StepNotes      = (int)StepNotesEnum.TravelDetailAcceptedByPMForProc;
                        travelDetailTrail.NextActionRole = (int)UserRoleEnum.Client1;
                    }
                    else if (objTravelDetailVM.IsProcedural == (int)ProcedureEnum.DirectFinalStep)
                    {
                        travelDetailTrail.StepNotes      = (int)StepNotesEnum.TravelDetailAcceptedByPMForProc;
                        travelDetailTrail.NextActionRole = (int)UserRoleEnum.Client2;
                    }
                }
                travelDetail.IsProcedural = objTravelDetailVM.IsProcedural;
                travelDetail.LastStatus   = objTravelDetailVM.LastStatus;
            }
            else if (objTravelDetailVM.RoleId == (int)UserRoleEnum.Client1)
            {
                if (objTravelDetailVM.LastStatus == (int)TravelRequestStatusEnum.RejectedByClient1)
                {
                    travelDetailTrail.NextActionRole = null;
                    travelDetailTrail.StepNotes      = (int)StepNotesEnum.RejectedByClient1;
                }
                else if (objTravelDetailVM.LastStatus == (int)TravelRequestStatusEnum.ApprovedByClient1)
                {
                    travelDetailTrail.NextActionRole = (int)UserRoleEnum.Client2;
                    travelDetailTrail.StepNotes      = (int)StepNotesEnum.ApprovedByClient1;
                }
                travelDetail.LastStatus = objTravelDetailVM.LastStatus;
            }
            else if (objTravelDetailVM.RoleId == (int)UserRoleEnum.Client2)
            {
                if (objTravelDetailVM.LastStatus == (int)TravelRequestStatusEnum.RejectedByClient2)
                {
                    travelDetailTrail.NextActionRole = null;
                    travelDetailTrail.StepNotes      = (int)StepNotesEnum.RejectedByClient2;
                }
                else if (objTravelDetailVM.LastStatus == (int)TravelRequestStatusEnum.ApprovedByClient2)
                {
                    travelDetailTrail.StepNotes      = (int)StepNotesEnum.ApprovedByClient2;
                    travelDetailTrail.NextActionRole = null;
                }
                travelDetail.LastStatus = objTravelDetailVM.LastStatus;
            }
            _travelRepository.UpdateTravelDetail(travelDetail);


            //travel detail trail logic start
            travelDetailTrail.StatusId    = objTravelDetailVM.LastStatus;
            travelDetailTrail.TravelId    = objTravelDetailVM.id;
            travelDetailTrail.ProcessedBy = objTravelDetailVM.UserID;
            travelDetailTrail.Comments    = objTravelDetailVM.Comments;
            travelDetailTrail.Date        = DateTime.Now;

            _travelRepository.AddTravelDetailTrail(travelDetailTrail);

            //travel detail trail logic end
        }
        public TravelDetailModel GetTravelDetail(int travelid)
        {
            TravelDetailModel traveldata = _travelRepository.GetTravelDetail(travelid);

            return(traveldata);
        }
 public TravelDetailModel InsertTraveldata(TravelDetailModel TravelData)
 {
     return(_travelRepository.AddTravelDetail(TravelData));
 }