public void GetAllShouldReturnAllTheInsertedProjects() { var getAll = projectService.GetAll(1, int.MaxValue); // Initial add in TestObjectFactory is 25 var expected = 25; Assert.AreEqual(expected, getAll.Count()); }
public override IActionResult Create() { ViewBag.Departements = departement.GetAll().ToList(); ViewBag.Projects = projects.GetAll().ToList(); ViewBag.LineManagers = _userHelper.GetByRoleName("Project Manager").ToList(); ViewBag.ProjectManagers = _userHelper.GetByRoleName("Project Manager").ToList(); ViewBag.AccountNames = accountName.GetAll().ToList(); Dictionary <string, bool> Status = new Dictionary <string, bool>(); Status.Add("Active", false); Status.Add("Close", true); ViewBag.ListStatus = Status.Select(x => new { Id = x.Value, Name = x.Key.ToString() }).ToList(); return(base.Create()); }
public async Task <IActionResult> Get(string language) { var projects = await _projectService.GetAll(); if (!string.IsNullOrEmpty(language)) { projects = projects.Where(p => p.Language == language); } if (User.Identity.IsAuthenticated) { projects = projects.Where(p => !p.Users.Select(u => u.Login).ToList().Contains(User.Identity.Name)); } projects = projects.Where(p => !p.Finished); return(View("Projects", projects)); }
// [ValidateAntiForgeryToken] public JsonResult Create([FromBody] Project a) { if (string.IsNullOrEmpty(a.Title)) { return(new JsonResult(new { message = "ProjectTitleMissing" })); } if (projectsService.GetAll().Any(p => p.Title == a.Title)) { return(new JsonResult(new { message = "ProjectTitleNotUnique" })); } string newProjectId = projectsService.Add(a, HttpContext.User); Project project = projectsService.Get(newProjectId, HttpContext.User); project.ProjectMemberIds = projectsService.GetProjectCreateModel(project.Id, HttpContext.User); project.UsernamesWithIds = projectsService.GetProjectCreateModel(null, HttpContext.User); return(new JsonResult(project)); }
public async Task <IActionResult> Get() { return(Ok(await _projectService.GetAll())); }
public IActionResult Get() { return(Json(_projectsService.GetAll())); }
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()); }
//[ResponseCache(Duration = 60)] public async Task <IEnumerable <tblProjects> > All() { return(await _projectsService.GetAll()); }
public override IActionResult Create() { //var Srf = _userHelper.GetCurrentSrfByLogin(User); //var Candidate = _candidate.GetById(Srf.CandidateId); //var travel = Service.GetAll().Where(x => x.ClaimType == ClaimType.TravelClaim && x.ContractorId.Equals(_userHelper.GetLoginUser(User)) // && x.StatusOne == StatusOne.Approved && x.StatusTwo == StatusTwo.Approved).Take(1); //var Vacancy =_vacancy.GetById(Candidate.VacancyId); //var Vacancy = Service.GetAll().Where(x => ) var CheckTravel = Service .GetAll() .Where(x => x.ClaimType == ClaimType.TravelClaim && x.ContractorId.Equals(_userHelper.GetUser(User).UserProfile.Id) && x.StatusOne == StatusOne.Approved && x.StatusTwo == StatusTwo.Approved && x.VacancyId.HasValue) .ToList() .Count(); var TravelClaimed = Service .GetAll() .Where(x => x.ClaimType == ClaimType.GeneralClaim && x.ContractorId.Equals(_userHelper.GetUser(User).UserProfile.Id)) .Select(x => x.TravelReqNo) .ToList(); ViewBag.TravelNotClaim = Service.GetAll().Where(x => !TravelClaimed.Contains(x.TravelReqNo) && x.ClaimType == ClaimType.TravelClaim && x.ContractorId.Equals(_userHelper.GetUser(User).UserProfile.Id) && x.StatusOne == StatusOne.Approved && x.StatusTwo == StatusTwo.Approved); //ViewBag.Vacancy = _vacancy.GetAll().Where(x => ) //ViewBag.CostCenter = _costCenter.GetAll().Where(x => x.Status == Status.Active).ToList(); //ViewBag.NetworkCode = _networkNumber.GetAll().Where(x => x.IsClosed == false).ToList(); ViewBag.Project = _project.GetAll().ToList(); //ViewBag.SubOrganizationUnit = _departmentSub.GetAll().ToList(); //ViewBag.Activity = _activity.GetAll().ToList(); // Auto Fll Form SRF //ViewBag.CostCenterId = Vacancy.CostCodeId; //ViewBag.NetworkNumberId = Vacancy.NetworkId; //ViewBag.SubOrganizatonId = Vacancy.DepartmentSubId; ViewBag.ClaimCategory = _claimCategory.GetAll().ToList(); if (CheckTravel > 0) { ViewBag.ClaimCategory = _claimCategory.GetAll().ToList(); } else { ViewBag.ClaimCategory = _claimCategory.GetAll().Where(x => !x.Name.Equals("Travel Allowance")).ToList(); } ViewBag.ProjectManager = _userHelper.GetByRoleName("Regional Project Manager").ToList(); ViewBag.LineManager = _userHelper.GetByRoleName("Line Manager").ToList(); ViewBag.DayType = Enum.GetValues(typeof(DayType)).Cast <DayType>().Select(v => new SelectListItem { Text = Extension.GetEnumDescription(v), Value = ((int)v).ToString() }).ToList(); ViewBag.Option = Enum.GetValues(typeof(AllowanceOptions)).Cast <AllowanceOptions>().Select(v => new SelectListItem { Text = Extension.GetEnumDescription(v), Value = ((int)v).ToString() }).ToList(); ViewBag.TripType = Enum.GetValues(typeof(TripType)).Cast <TripType>().Select(v => new SelectListItem { Text = Extension.GetEnumDescription(v), Value = ((int)v).ToString() }).ToList(); ViewBag.AllowForm = JsonConvert.SerializeObject(_allowForm.GetAll().OrderBy(x => x.Name).Select(x => x.Value).ToList()); //if (Vacancy.isManager) //{ // ViewBag.IsManager = '1'; //} //else //{ ViewBag.IsManager = '0'; //} return(base.Create()); }