예제 #1
0
 public async Task <ActionResult> Create(Department department)
 {
     try
     {
         DepartmentRepository.CreateDepartment(department);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
예제 #2
0
        public async Task <Department> CreateDepartment([Service] DepartmentRepository departmentRepository,
                                                        [Service] ITopicEventSender eventSender, string departmentName)
        {
            var newDepartment = new Department
            {
                Name = departmentName
            };
            var createdDepartment = await departmentRepository.CreateDepartment(newDepartment);

            await eventSender.SendAsync("DepartmentCreated", createdDepartment);

            return(createdDepartment);
        }
 public async Task <ActionResult> Create(Department model)
 {
     try
     {
         // TODO: Add insert logic here
         DepartmentRepository.CreateDepartment(model);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
예제 #4
0
 public ActionResult Create(DepartmentForCreateDto departmentForCreateDto)
 {
     if (ModelState.IsValid)
     {
         Department department = new Department
         {
             Name      = departmentForCreateDto.DepartmentName,
             ManagerId = departmentForCreateDto.SelectedManagerId
         };
         _departmentRepository.CreateDepartment(department);
         return(RedirectToAction("index"));
     }
     return(View());
 }
예제 #5
0
 public bool Create(Department department, string token)
 {
     try
     {
         if (ModelState.IsValid)
         {
             department.CreatedBy   = _userStatistics.UserId;
             department.CreatedDate = DateTime.Now;
             if (objRep.CreateDepartment(department))
             {
                 SaveFiles(token, this.GetType().Name, department.DepartmentId);
                 return(true);
             }
             return(false);
         }
         return(false);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
        private async void CreateDepartmentBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Employee objektet sættes til at få jobtitel 1 hvilket er en boss jobtitel
                chosenBoss.JobTitle = 1;
                //Der laves et nyt department object hvor navnet på department sættes til at være tekstboks værdi og valgt id firma department tilhører sættes
                Department newDep = new Department();
                newDep.Name = DepartmentName.TextBoxField.Text;
                //Brugeren kan kun vælge lovlige id'er, derfor valideres der ikke
                newDep.CompanyId = ChosenCompanyId;
                //Den nye department sendes til oprettelse med employee der er sat til at være chef for afdelingen
                await depRep.CreateDepartment(newDep, chosenBoss);

                statusLabel.Content = "Department created";
                loadDepartments();
            }
            catch
            {
                statusLabel.Content = "An error occured";
            }
        }
        public void CreateDepartment(string dptName)
        {
            var repo = new DepartmentRepository();

            repo.CreateDepartment(dptName);
        }
예제 #8
0
 public async Task CreateDepartment(Department department)
 {
     await _departmentRepository.CreateDepartment(department).ConfigureAwait(false);
 }