Example #1
0
        public override IActionResult Edit(string id, RecoveryForm model)
        {
            if (ModelState.IsValid)
            {
                var User = _userHelper.GetUser(id);
                if (User != null)
                {
                    // Insert Vacancy
                    var NewVacancy = new VacancyList();
                    NewVacancy.AccountNameId         = model.AccountNameId;
                    NewVacancy.ApproverOneId         = model.ApproverOneId;
                    NewVacancy.ApproverTwoId         = model.SourcingId;
                    NewVacancy.CostCodeId            = model.CostCodeId;
                    NewVacancy.CreatedAt             = DateTime.Now;
                    NewVacancy.DepartmentId          = model.DepartmentId;
                    NewVacancy.DepartmentSubId       = model.DepartmentSubId;
                    NewVacancy.JobStageId            = model.JobStageId;
                    NewVacancy.JoinDate              = model.JoinDate;
                    NewVacancy.NetworkId             = model.NetworkId;
                    NewVacancy.NoarmalRate           = model.NoarmalRate;
                    NewVacancy.OtLevel               = model.OtLevel;
                    NewVacancy.RequestBy             = _userHelper.GetUserProfile(model.ApproverOneId);
                    NewVacancy.PackageTypeId         = model.PackageTypeId;
                    NewVacancy.ServicePackCategoryId = model.ServicePackCategoryId;
                    NewVacancy.ServicePackId         = model.ServicePackId;
                    //NewVacancy.Status = VacanStatusFive.Done;
                    NewVacancy.VacancyStatus = ApproverStatus.Completed;
                    NewVacancy.isHrms        = model.isHrms;
                    NewVacancy.isLaptop      = model.isLaptop == 1 ? true : false;
                    NewVacancy.isManager     = model.isManager;
                    NewVacancy.isUsim        = model.isUsim;
                    NewVacancy.StatusOne     = SrfApproveStatus.Approved;
                    NewVacancy.StatusTwo     = SrfApproveStatus.Approved;
                    NewVacancy.StatusThree   = SrfApproveStatus.Approved;
                    NewVacancy.StatusFourth  = SrfApproveStatus.Approved;
                    _vacancy.Add(NewVacancy);

                    if (NewVacancy.Id != null)
                    {
                        // Insert Candidate
                        var UserProfile  = _profileService.GetByUserId(id);
                        var GetCandidate = _candidate.GetAll().Where(x => x.AccountId == UserProfile.Id).FirstOrDefault();

                        if (GetCandidate == null)
                        {
                            var Candidate = new CandidateInfo();
                            Candidate.Account           = UserProfile;
                            Candidate.Address           = UserProfile.Address;
                            Candidate.AgencyId          = model.AgencyId;
                            Candidate.AgencyType        = AgencyType.Agency;
                            Candidate.ApproveOneDate    = DateTime.Now;
                            Candidate.ApproveOneStatus  = ApproverStatus.Selected;
                            Candidate.ApproveTwoeDate   = DateTime.Now;
                            Candidate.CreatedAt         = DateTime.Now;
                            Candidate.Email             = User.Email;
                            Candidate.Gender            = UserProfile.Gender.Value;
                            Candidate.HomePhoneNumber   = UserProfile.HomePhoneNumber;
                            Candidate.IdNumber          = UserProfile.IdNumber;
                            Candidate.IsCandidate       = false;
                            Candidate.IsContractor      = true;
                            Candidate.IsUser            = true;
                            Candidate.Martial           = Martial.M1;
                            Candidate.MobilePhoneNumber = UserProfile.MobilePhoneNumber;
                            Candidate.Name             = UserProfile.Name;
                            Candidate.Nationality      = "Indonesia";
                            Candidate.NickName         = UserProfile.Name;
                            Candidate.PlaceOfBirth     = UserProfile.Birthplace;
                            Candidate.DateOfBirth      = UserProfile.Birthdate.Value;
                            Candidate.RequestBy        = _userHelper.GetUserProfile(model.AgencyId);
                            Candidate.ApproveTwoStatus = ApproverStatus.Completed;
                            Candidate.Vacancy          = NewVacancy;
                            GetCandidate = _candidate.Add(Candidate);
                        }

                        if (GetCandidate != null)
                        {
                            var Department = _department.GetById(model.DepartmentId);
                            var Network    = _network.GetById(model.NetworkId);
                            // Insert SRF
                            SrfRequest NewSrf = new SrfRequest();
                            NewSrf.CreatedAt          = DateTime.Now;
                            NewSrf.Number             = "0000";
                            NewSrf.Type               = SrfType.New;
                            NewSrf.ApproveStatusOne   = SrfApproveStatus.Approved;
                            NewSrf.ApproveStatusTwo   = SrfApproveStatus.Approved;
                            NewSrf.ApproveStatusThree = SrfApproveStatus.Approved;
                            NewSrf.ApproveStatusFour  = SrfApproveStatus.Approved;
                            NewSrf.ApproveStatusFive  = SrfApproveStatus.Approved;
                            NewSrf.ApproveStatusSix   = SrfApproveStatus.Approved;
                            NewSrf.RequestBy          = _userHelper.GetUserProfile(model.ApproverOneId).Name;
                            NewSrf.SrfBegin           = model.SrfBegin;
                            NewSrf.SrfEnd             = model.SrfEnd;
                            NewSrf.ServiceLevel       = model.OtLevel;
                            NewSrf.isWorkstation      = model.isLaptop == 1 ? true  : false;
                            NewSrf.isCommunication    = model.isUsim;
                            NewSrf.IsHrms             = model.isHrms;
                            NewSrf.IsOps              = Department.OperateOrNon == 1 ? true : false;
                            NewSrf.IsManager          = false;
                            NewSrf.RateType           = Domain.Models.Enum.RateType.Normal;
                            NewSrf.IsExtended         = false;
                            NewSrf.IsLocked           = false;
                            NewSrf.Status             = Domain.Models.Enum.SrfStatus.Done;
                            NewSrf.SpectValue         = 0;
                            NewSrf.IsActive           = false;
                            NewSrf.ServicePackId      = model.ServicePackId;
                            NewSrf.NetworkId          = model.NetworkId;
                            NewSrf.CostCenterId       = model.CostCodeId;
                            NewSrf.LineManagerId      = model.ApproverOneId;
                            NewSrf.ActivityCode       = _activity.GetAll().OrderBy(x => Guid.NewGuid()).FirstOrDefault();
                            NewSrf.DepartmentId       = model.DepartmentId;
                            NewSrf.DepartmentSubId    = model.DepartmentSubId;
                            NewSrf.ProjectManagerId   = Network.ProjectManagerId;
                            NewSrf.ApproveOneId       = model.ApproverOneId;
                            NewSrf.ApproveTwoId       = model.ApproveTwoId;
                            NewSrf.ApproveThreeId     = model.ApproveThreeId;
                            NewSrf.ApproveFourId      = model.ApproveFourId;
                            NewSrf.ApproveSixId       = model.ApproveSixId;
                            NewSrf.Candidate          = GetCandidate;
                            NewSrf.AccountId          = model.AccountNameId;
                            NewSrf.IsLocked           = false;
                            NewSrf.IsActive           = true;
                            var AnnualLeave = MonthDistance(model.SrfBegin, model.SrfEnd);
                            NewSrf.AnnualLeave = AnnualLeave;
                            Service.Add(NewSrf);
                            if (NewSrf.Id != null)
                            {
                                TempData["Success"] = true;
                            }
                        }
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
Example #2
0
        private void Srf()
        {
            Data dt = new Data("srf");

            foreach (var row in dt.GetData())
            {
                int  index          = 1;
                var  Data           = (List <String>)row;
                var  Email          = Data[index].ToString(); index += 1;
                var  CreatedAt      = Data[index].ToString(); index += 1;
                var  SrfNumber      = Data[index].ToString(); index += 1;
                var  IsOps          = Data[index].ToString(); index += 1;
                var  SrfLineManager = Data[index].ToString(); index += 1;
                var  SrfHeadOfSL    = Data[index].ToString(); index += 1;
                var  SrfHeadOfOps   = Data[index].ToString(); index += 1;
                var  SrfOrNon       = Data[index].ToString(); index += 1;
                var  SrfHsrc        = Data[index].ToString(); index += 1;
                var  SerCoord       = Data[index].ToString(); index += 1;
                var  DateApprov1    = Data[index].ToString(); index += 1;
                var  DateApprov2    = Data[index].ToString(); index += 1;
                var  DateApprov3    = Data[index].ToString(); index += 1;
                var  DateApprov4    = Data[index].ToString(); index += 1;
                var  DateApprov5    = Data[index].ToString(); index += 1;
                var  DateApprov6    = Data[index].ToString(); index += 1;
                var  SrfStatus      = Data[index].ToString(); index += 1;
                var  SrfBegin       = Data[index].ToString(); index += 1;
                var  SrfEnd         = Data[index].ToString(); index += 1;
                var  RateType       = Data[index].ToString(); index += 1;
                var  ActivityCod    = Data[index].ToString(); index += 1;
                var  SRF_LM         = _userProfile.GetAll().Where(x => Truncate(x.Name) == Truncate(SrfLineManager)).FirstOrDefault();
                var  SRF_HSL        = _userProfile.GetAll().Where(x => Truncate(x.Name) == Truncate(SrfHeadOfSL)).FirstOrDefault();
                var  SRF_OPS        = _userProfile.GetAll().Where(x => Truncate(x.Name) == Truncate(SrfHeadOfOps)).FirstOrDefault();
                var  SRF_NONOPS     = _userProfile.GetAll().Where(x => Truncate(x.Name) == Truncate(SrfHeadOfOps)).FirstOrDefault();
                var  SRF_HOSRC      = _userProfile.GetAll().Where(x => Truncate(x.Name) == Truncate(SrfHsrc)).FirstOrDefault();
                var  SRF_SRCRD      = _userProfile.GetAll().Where(x => Truncate(x.Name) == Truncate(SerCoord)).FirstOrDefault();
                bool WhatOps        = !string.IsNullOrEmpty(SrfHeadOfOps) ? true : false;

                var Candidate = _candidate.GetAll().Where(x => Truncate(x.Email) == Truncate(Email)).FirstOrDefault();
                if (Candidate != null)
                {
                    var Vacancy           = _vacancy.GetById(Candidate.VacancyId);
                    var Network           = _networkNumber.GetById(Vacancy.NetworkId);
                    var Type              = SrfType.New;
                    var AnnualLeave       = MonthDistance(DateTime.Parse(SrfBegin), DateTime.Parse(SrfEnd));
                    var ParentId          = (String)null;
                    var CheckCandidateSrf = _srf.GetAll().Where(x => x.Candidate == Candidate).OrderByDescending(x => x.SrfEnd).FirstOrDefault();
                    if (CheckCandidateSrf != null)
                    {
                        Type        = SrfType.Extension;
                        ParentId    = CheckCandidateSrf.Id.ToString();
                        AnnualLeave = AnnualLeave + CheckCandidateSrf.AnnualLeave;
                    }

                    //# Create NewSrf SRF
                    SrfRequest NewSrf = new SrfRequest();
                    NewSrf.CreatedAt        = !string.IsNullOrEmpty(CreatedAt) ? DateTime.Parse(CreatedAt) : DateTime.MinValue;
                    NewSrf.Number           = SrfNumber;
                    NewSrf.Type             = Type;
                    NewSrf.ApproveStatusOne = SrfApproveStatus.Submitted;
                    if (Truncate(RateType) == Truncate("Normal"))
                    {
                        NewSrf.ApproveStatusTwo = SrfApproveStatus.Approved;
                        if (WhatOps == true)
                        {
                            NewSrf.ApproveStatusThree = SrfApproveStatus.Approved;
                            NewSrf.ApproveStatusFour  = SrfApproveStatus.Waiting;
                        }
                        else
                        {
                            NewSrf.ApproveStatusThree = SrfApproveStatus.Waiting;
                            NewSrf.ApproveStatusFour  = SrfApproveStatus.Approved;
                        }
                        NewSrf.ApproveStatusSix = SrfApproveStatus.Approved;
                    }
                    else
                    {
                        NewSrf.ApproveStatusFive = SrfApproveStatus.Approved;
                    }

                    NewSrf.RequestBy       = SRF_LM.Name;
                    NewSrf.SrfBegin        = !string.IsNullOrEmpty(SrfBegin) ? DateTime.Parse(SrfBegin) : DateTime.MinValue;
                    NewSrf.SrfEnd          = !string.IsNullOrEmpty(SrfEnd) ? DateTime.Parse(SrfEnd) : DateTime.MinValue;
                    NewSrf.ServiceLevel    = Vacancy.OtLevel;
                    NewSrf.isWorkstation   = Vacancy.isLaptop;
                    NewSrf.isCommunication = Vacancy.isUsim;
                    NewSrf.IsHrms          = Vacancy.isHrms;
                    NewSrf.IsOps           = WhatOps;
                    NewSrf.IsManager       = false;

                    if (Truncate(RateType) == Truncate("Normal"))
                    {
                        NewSrf.RateType = Domain.Models.Enum.RateType.Normal;
                    }
                    else
                    {
                        NewSrf.RateType   = Domain.Models.Enum.RateType.SpecialRate;
                        NewSrf.SpectValue = Vacancy.NoarmalRate;
                    }

                    NewSrf.IsExtended       = (Type == SrfType.New) ? false : true;
                    NewSrf.IsLocked         = false;
                    NewSrf.Status           = Domain.Models.Enum.SrfStatus.Done;
                    NewSrf.SpectValue       = 0;
                    NewSrf.IsActive         = false;
                    NewSrf.ServicePackId    = Vacancy.ServicePackId;
                    NewSrf.NetworkId        = Vacancy.NetworkId;
                    NewSrf.CostCenterId     = Vacancy.CostCodeId;
                    NewSrf.LineManagerId    = Vacancy.ApproverOneId.Value;
                    NewSrf.ActivityCode     = _activity.GetAll().Where(x => Truncate(x.Code) == Truncate(ActivityCod)).FirstOrDefault();
                    NewSrf.DepartmentId     = Vacancy.DepartmentId;
                    NewSrf.DepartmentSubId  = Vacancy.DepartmentSubId;
                    NewSrf.ProjectManagerId = Network.ProjectManagerId;
                    NewSrf.ApproveOneBy     = SRF_LM;
                    NewSrf.ApproveTwoBy     = SRF_HSL;
                    if (WhatOps == true)
                    {
                        NewSrf.ApproveThreeBy = SRF_OPS;
                    }
                    else
                    {
                        NewSrf.ApproveFourBy = SRF_NONOPS;
                    }
                    NewSrf.ApproveSixBy = SRF_SRCRD;
                    NewSrf.Candidate    = Candidate;
                    NewSrf.AccountId    = Vacancy.AccountNameId;

                    if (!string.IsNullOrEmpty(ParentId))
                    {
                        NewSrf.ExtendFrom = Guid.Parse(ParentId);
                    }

                    NewSrf.AnnualLeave = AnnualLeave;
                    _srf.Add(NewSrf);

                    if (Truncate(RateType) != Truncate("Normal"))
                    {
                        // # Create Escalasi in NewSrf

                        var Escalation = new SrfEscalationRequest();
                        Escalation.OtLevel            = NewSrf.ServiceLevel;
                        Escalation.IsWorkstation      = NewSrf.isWorkstation;
                        Escalation.IsCommnunication   = NewSrf.isCommunication;
                        Escalation.SparateValue       = Vacancy.NoarmalRate;
                        Escalation.Status             = StatusEscalation.Done;
                        Escalation.ApproveStatusOne   = SrfApproveStatus.Approved;
                        Escalation.ApproveStatusTwo   = SrfApproveStatus.Approved;
                        Escalation.ApproveStatusThree = SrfApproveStatus.Approved;
                        Escalation.ApproveStatusFour  = SrfApproveStatus.Approved;
                        Escalation.Note          = "";
                        Escalation.ServicePackId = NewSrf.ServicePackId;
                        Escalation.SrfRequest    = NewSrf;
                        _escalation.Add(Escalation);
                    }

                    if (NewSrf != null)
                    {
                        Count++;
                        Console.WriteLine(Data[0] + " " + Email + " Srf  with " + SrfNumber + "  from " + SrfBegin + " to " + SrfEnd + "  has been saved ");
                    }
                }
                else
                {
                    Console.WriteLine(Data[0] + " " + Email);
                }
            }

            Console.WriteLine(Count + " Srf record has been saved ");
        }
Example #3
0
        public override IActionResult Edit(Guid id)
        {
            try
            {
                var item = Service.GetById(id);
                var Vacancy = _vacancy.GetById(_candidate.GetById(item.CandidateId).VacancyId);
                var Departement = _department.GetById(item.DepartmentId);
                var PackageType = _packageType.GetById(Vacancy.PackageTypeId);
                ViewBag.PriceType = PackageType.Name;
                ViewBag.Vacancy = Vacancy;
                ViewBag.Candidate = _candidate.GetById(item.CandidateId);
                ViewBag.Departement = _department.GetById(item.DepartmentId);
                ViewBag.SSOW = _ssow.GetById(item.ServicePackId);
                ViewBag.SCategory = _ssowCategory.GetById(_ssow.GetById(item.ServicePackId).ServicePackCategoryId);
                ViewBag.JobsStage = _jobStage.GetById(Vacancy.JobStageId);
                ViewBag.ListDepartement = _department.GetAll().ToList();
                if (Departement.OperateOrNon == 1)
                {
                    ViewBag.HeadOperation = _userHelper.GetByRoleName("Head Of Operation").ToList();
                }
                else
                {
                    ViewBag.HeadOperation = _userHelper.GetByRoleName("Head Of Non Operation").ToList();
                }
                ViewBag.isOperation = Departement.OperateOrNon;
                ViewBag.ListServiceLine = _userHelper.GetByRoleName("Head Of Service Line").ToList();
                ViewBag.ListServiceCordinator = _userHelper.GetByRoleName("Service Coordinator").ToList();
                ViewBag.ListAccount = _account.GetAll().ToList();
                ViewBag.ListSubDepartment = _departmentSub.GetAll().Where(x => x.DepartmentId.Equals(item.DepartmentId)).ToList();
                ViewBag.ListCostCenter = _costCenter.GetAll().Where(x => x.DepartmentId.Equals(item.DepartmentId)).ToList();
                ViewBag.ListNetwork = _network.GetAll().Where(x => x.DepartmentId.Equals(item.DepartmentId) && x.IsClosed == false).ToList();
                ViewBag.Id = id;
                ViewBag.isOperation = Departement.OperateOrNon;
                ViewBag.txtOperaion = (Departement.OperateOrNon == 1) ? "Operational" : "Non Operational";
                ViewBag.FormDisable = 1;
                ViewBag.SrfNumber = Service.GenerateNumnber();
                ViewBag.NowYear = DateTime.Now.Year.ToString("yy");

                // Aditional
                Dictionary<string, int> ws = new Dictionary<string, int>();
                ws.Add("No", 0);
                ws.Add("Yes", 1);

                Dictionary<string, bool> com = new Dictionary<string, bool>();
                com.Add("No USIM", false);
                com.Add("USIM", true);

                Dictionary<string, bool> sign = new Dictionary<string, bool>();
                sign.Add("Non-HRMS", false);
                sign.Add("HRMS", true);

                Dictionary<string, bool> manager = new Dictionary<string, bool>();
                manager.Add("Manager", true);
                manager.Add("Non Manager", false);

                ViewBag.PackageType = _packageType.GetAll().ToList();
                ViewBag.ServicePackCategory = _ssowCategory.GetAll().ToList();
                ViewBag.ServicePack = _ssow.GetAll().Where(x => x.Type == (PackageTypes)Enum.Parse(typeof(PackageTypes), PackageType.Name)).ToList();
                ViewBag.BasicServiceLevel = new List<int>(new int[] { 0, 20, 30, 40 }).Select(x => new { Id = x, Name = x.ToString() });
                ViewBag.WorkstationService = ws.Select(x => new { Id = x.Value, Name = x.Key.ToString() }).ToList();
                ViewBag.CommunicationService = com.Select(x => new { Id = x.Value, Name = x.Key.ToString() }).ToList();
                ViewBag.Signum = sign.Select(x => new { Id = x.Value, Name = x.Key.ToString() }).ToList();
                ViewBag.IsManager = manager.Select(x => new { Id = x.Value, Name = x.Key.ToString() }).ToList();
                ViewBag.Jobstage = _jobStage.GetAll().Where(x => !string.IsNullOrEmpty(x.Description)).ToList();
                ViewBag.ListAgency = _userHelper.GetByRoleName("HR Agency").ToList();
                ViewBag.ListActivity = _activity.GetAll().ToList();
                ViewBag.ListExtended = Service.GetAll().Where(x => x.CandidateId.Equals(item.CandidateId) && x.SrfEnd >= item.SrfBegin).ToList();
                ViewBag.ListLineManager = _userHelper.GetByRoleName("Line Manager").ToList();
                ViewBag.ListHeadOfSourcing = _userHelper.GetByRoleName("Head Of Sourcing").ToList();
                ViewBag.ListSrfStatus = new List<SrfApproveStatus>(new SrfApproveStatus[] { SrfApproveStatus.Waiting, SrfApproveStatus.Approved }).Select(x => new { Id = x, Name = x.ToString() });
                ViewBag.ListTypeSRF = new List<SrfType>(new SrfType[] { SrfType.New, SrfType.Extension }).Select(x => new { Id = x, Name = x.ToString() });
                ViewBag.LisStatusSrf = new List<SrfStatus>(new SrfStatus[] { SrfStatus.Done,SrfStatus.Terminate,SrfStatus.Blacklist }).Select(x => new { Id = x, Name = x.ToString() });

                var Model = Mapper.Map<SrfRequestModelForm>(item);
                Model.FormVacancy = Mapper.Map<VacancyListFormModel>(Vacancy);
                if(item.Status == SrfStatus.Waiting)
                {
                    Model.Status = SrfStatus.Done;
                }

                var CandidateInfo = _candidate.GetById(item.CandidateId);
                if(CandidateInfo!=null)
                {
                    Model.AgencyId = CandidateInfo.AgencyId.Value;
                }

                var Esc = _escalation.GetAll().Where(x => x.SrfId.Equals(id)).FirstOrDefault();
                if(Esc==null)
                {
                    ViewBag.IsEscalation = false;
                }
                else
                {
                    ViewBag.IsEscalation = true;
                }
                    
                return View(Model);


            }
            catch (Exception e)
            {
                return Content(e.ToString());
            }
        }
Example #4
0
        public override IActionResult Edit(Guid id)
        {
            var item = Service.GetById(id);
            var Srf  = _userHelper.GetCurrentSrfByLogin(User);

            ViewBag.Id = id;
            ViewBag.OrganizationUnit = _department.GetAll().ToList();
            ViewBag.CostCenter       = _cost.GetAll().Where(x => x.Status == Status.Active).ToList();
            ViewBag.AccountName      = _account.GetAll().ToList();
            ViewBag.NetworkNumber    = _network.GetAll().Where(x => x.IsClosed == false).ToList();
            ViewBag.Project          = _project.GetAll().ToList();
            ViewBag.Code             = _code.GetAll().ToList();
            ViewBag.SubOperasional   = _subOp.GetAll().ToList();
            ViewBag.City             = _city.GetAll().ToList();
            ViewBag.Annual           = Srf.AnnualLeave;
            // Start - Menampilkan Time Sheet
            var jan1 = new DateTime(DateTime.Today.Year, 1, 1);

            if (DateTime.Now.Month == 1)
            {
                jan1 = new DateTime(DateTime.Today.Year - 1, 12, 1);
            }

            var firstWeek = jan1.AddDays(1 - (int)(jan1.DayOfWeek));
            var weeks     = Enumerable.Range(0, 54).Select(i => new
                                                           { weekStart = firstWeek.AddDays(i * 7) })
                            .TakeWhile(x => x.weekStart.Year <= jan1.Year)
                            .Select(x => new { x.weekStart, weekFinish = x.weekStart.AddDays(6) })
                            .SkipWhile(x => x.weekFinish < jan1.AddDays(1))
                            .Select((x, i) => new
                                    { x.weekStart, x.weekFinish, weekNum = i + 1 });

            if (DateTime.Now.Month == 1)
            {
                weeks = Enumerable.Range(0, 54).Select(i => new
                                                       { weekStart = firstWeek.AddDays(i * 7) })
                        .TakeWhile(x => x.weekStart.Year <= DateTime.Now.Year)
                        .Select(x => new { x.weekStart, weekFinish = x.weekStart.AddDays(6) })
                        .SkipWhile(x => x.weekFinish < jan1.AddDays(1))
                        .Select((x, i) => new
                                { x.weekStart, x.weekFinish, weekNum = i + 1 });
            }

            DateTime         Today       = Convert.ToDateTime(DateTime.Now.Date.ToString());
            string           SelectWeeks = "";
            List <WeeksList> WeekList    = new List <WeeksList>();
            List <DateList>  DateList    = new List <DateList>();
            int num = 0;

            foreach (var X in weeks)
            {
                DateTime CurrentDay = Today.Date;
                if (Today.DayOfWeek != DayOfWeek.Sunday)
                {
                    CurrentDay = Today.Date.AddDays(7);
                }

                if (DateTime.Now.Month == 1)
                {
                    if (X.weekStart.Date <= CurrentDay.Date && X.weekFinish.Date <= CurrentDay.Date)
                    {
                        SelectWeeks = X.weekStart.ToString("dd MMM yyyy") + " - " + X.weekFinish.ToString("dd MMM yyyy");
                        var Value = X.weekStart.ToString("yyyy-MM-dd") + ";" + X.weekFinish.ToString("yyyy-MM-dd") + ";" + X.weekNum;
                        WeekList.Add(new WeeksList {
                            Weeks = Value, SelectDates = SelectWeeks
                        });
                        for (var dt = X.weekStart; dt <= X.weekFinish; dt = dt.AddDays(1))
                        {
                            DateList.Add(new DateList {
                                Weeks = X.weekNum, Date = dt, DateName = dt.DayOfWeek.ToString()
                            });
                            num = X.weekNum;
                        }
                    }
                }
                else
                {
                    if (X.weekStart.Date <= CurrentDay.Date && X.weekFinish.Date <= CurrentDay.Date && X.weekFinish.Year == Today.Year)
                    {
                        SelectWeeks = X.weekStart.ToString("dd MMM yyyy") + " - " + X.weekFinish.ToString("dd MMM yyyy");
                        var Value = X.weekStart.ToString("yyyy-MM-dd") + ";" + X.weekFinish.ToString("yyyy-MM-dd") + ";" + X.weekNum;
                        WeekList.Add(new WeeksList {
                            Weeks = Value, SelectDates = SelectWeeks
                        });
                        for (var dt = X.weekStart; dt <= X.weekFinish; dt = dt.AddDays(1))
                        {
                            DateList.Add(new DateList {
                                Weeks = X.weekNum, Date = dt, DateName = dt.DayOfWeek.ToString()
                            });
                            num = X.weekNum;
                        }
                    }
                }
            }

            var TimeSelected = (string)item.DateStart.ToString("yyyy-MM-dd") + ";" + item.DateEnd.ToString("yyyy-MM-dd") + ";" + num;
            var Selected     = item.DateStart.ToString("dd MMM yyyy") + " - " + item.DateEnd.ToString("dd MMM yyyy");

            DateList.Add(new DateList {
                Weeks = num, Date = item.DateStart, DateName = item.DateStart.DayOfWeek.ToString()
            });
            WeekList.Add(new WeeksList {
                Weeks = TimeSelected, SelectDates = Selected
            });

            ViewBag.TimeSelected   = TimeSelected;
            ViewBag.Weeks          = JsonConvert.SerializeObject(WeekList);
            ViewBag.Dates          = JsonConvert.SerializeObject(DateList);
            ViewBag.LineManager    = _userHelper.GetByRoleName("Line Manager").ToList();
            ViewBag.ProjectManager = _userHelper.GetByRoleName("Project Manager").ToList();
            ViewBag.Activity       = _actiivity.GetAll().ToList();
            ViewBag.TimeSheetType  = _timesheet.GetAll().ToList();
            if (item != null)
            {
                var model     = Mapper.Map <AttendaceExceptionListModelForm>(item);
                var ListHours = string.Join(",", _attendanceRecord.GetAll().Where(x => x.AttendaceExceptionListId.Equals(item.Id)).Select(x => x.Hours).ToArray());
                var ListDate  = string.Join(",", _attendanceRecord.GetAll().Where(x => x.AttendaceExceptionListId.Equals(item.Id)).Select(x => x.AttendanceRecordDate.ToString("yyyy-MM-dd")).ToArray());
                model.Hours = ListHours;
                model.AttendanceRecordDate = ListDate;
                return(View(model));
            }
            return(NotFound());
        }