public async Task <Department> AddDepartmentAsync(string name, bool status)
        {
            var department = await _employeeRepository.AddDepartment(new Department(Guid.NewGuid(), name, status));

            await _employeeRepository.UnitOfWork.SaveChangesAsync();

            return(department);
        }
Пример #2
0
 public IActionResult AddNewDepartment([FromBody] DepartmentEmployeeDetailsDto newDepartment,
                                       [FromHeader(Name = "id_token")] string googleToken)
 {
     try
     {
         if (googleAuth.ProcessRequestAtGoogle(googleToken))
         {
             var DepartAddStatus = empRepository.AddDepartment(newDepartment);
             return(Ok(Json(DepartAddStatus)));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception exp)
     {
         return(NotFound(@"Can't add the given Department"));
     }
 }
Пример #3
0
        /// <summary>
        /// Add department to the database on click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonAddDept_Click(object sender, EventArgs e)
        {
            try
            {
                string deptName = textBox6.Text;

                employer.AddDepartment(deptName);
                textBox6.Text = "";
                var temp  = employer.GetAllDept();
                var temp1 = new List <string>();
                foreach (var item in temp)
                {
                    temp1.Add($"{item.Department_Name}");
                }
                listBox1.DataSource = temp1;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Encountered");
            }
        }
 public int AddDepartment([FromBody] Department dept1, string DepartmentName)
 {
     return(_employeeRepository.AddDepartment(dept1, DepartmentName));
 }