public List <DepartmentResult> Get(int departmentId) { List <DepartmentResult> result = new List <DepartmentResult>(); if (departmentId == 0 && IsSystem) { // Get All var departments = _departmentsService.GetAll(); foreach (var department in departments) { result.Add(DepartmentToResult(department)); } return(result); } else if (departmentId >= 1) { if (departmentId == DepartmentId) { var department = _departmentsService.GetDepartmentById(departmentId); result.Add(DepartmentToResult(department)); return(result); } else { throw HttpStatusCode.Unauthorized.AsException(); } } else { throw HttpStatusCode.BadRequest.AsException(); } }
public ActionResult Index() { TempData.Keep("employeInfo"); var employeInfo = (HomeModel)TempData["employeInfo"]; var info = _employesService.GetEmployeById(employeInfo.Id); var departments = _departmentsService.GetAll().Select(domain => domain.Name).ToList(); var dataLang = _languagesService.GetAll(); var languages = dataLang.Select(domain => domain.Name).ToList(); var model = new EditModel() { Id = employeInfo.Id, LastName = info.LastName, FirstName = info.FirstName, Age = info.Age, Department = info.Department.Name, SelectedLanguage = dataLang.FirstOrDefault(lang => lang.LanguageId == info.Experience.LanguageId).Name, Departments = departments, Languages = languages }; return(View(model)); }
public ActionResult Index() { var names = _employesService.GetAllEmployes().Select(domain => domain.FirstName).ToList(); var departments = _departmentsService.GetAll().Select(domain => new DepartmentModel() { DepartmentId = domain.DepartmentId, DepartmentName = domain.Name }).ToList(); var languages = _languagesService.GetAll().Select(domain => new LanguagesModel() { LanguageId = domain.LanguageId, Name = domain.Name }).ToList(); var model = new AddModel() { Departments = departments, Languages = languages, Names = names }; return(View(model)); }
public IActionResult List() { ViewBagMethod(); var list = _departmentsService.GetAll("Courses"); return(View(list)); }
public JsonResult ListDepartmentCombo() { List <Departments> list = new List <Departments>(); list = _departmentsService.GetAll(); list.Insert(0, new Departments() { Uid = Guid.Empty, Name = "Bölüm Seçiniz" }); return(Json(new SelectList(list, "Uid", "Name"))); }
public List <UnitResult> GetUnitsForDepartment(int departmentId) { var results = new List <UnitResult>(); if (departmentId != DepartmentId && !IsSystem) { throw HttpStatusCode.Unauthorized.AsException(); } if (departmentId == 0 && IsSystem) { // Get All var departments = _departmentsService.GetAll(); foreach (var department in departments) { var units = _unitsService.GetUnitsForDepartment(departmentId); foreach (var u in units) { var unitResult = new UnitResult(); unitResult.Id = u.UnitId; unitResult.DepartmentId = u.DepartmentId; unitResult.Name = u.Name; unitResult.Type = u.Type; unitResult.StationId = u.StationGroupId; unitResult.VIN = u.VIN; unitResult.PlateNumber = u.PlateNumber; unitResult.FourWheel = u.FourWheel; unitResult.SpecialPermit = u.SpecialPermit; results.Add(unitResult); } } return(results); } else { var units = _unitsService.GetUnitsForDepartment(departmentId); foreach (var u in units) { var unitResult = new UnitResult(); unitResult.Id = u.UnitId; unitResult.DepartmentId = u.DepartmentId; unitResult.Name = u.Name; unitResult.Type = u.Type; unitResult.StationId = u.StationGroupId; unitResult.VIN = u.VIN; unitResult.PlateNumber = u.PlateNumber; unitResult.FourWheel = u.FourWheel; unitResult.SpecialPermit = u.SpecialPermit; results.Add(unitResult); } } return(results); }