예제 #1
0
 public ActionResult Create(Department dept)
 {
     try
     {
         if (dept.Id > 0)
         {
             bool Update = department.UpdateDepartment(dept);
             return(RedirectToAction("Index"));
         }
         else
         {
             bool Added = department.AddDepartment(dept);
             if (Added == true)
             {
                 TempData["message"] = "Department Added Success...";
                 return(RedirectToAction("Index"));
             }
             else
             {
                 TempData["message"] = "Unable to create new department...";
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
예제 #2
0
        public Department AddDepartment(DepartmentAddEditArgs args)
        {
            Department returnItem = null;

            IDepartmentManager proxy1 = this.GetTheProxy();

            using (proxy1 as IDisposable)
            {
                returnItem = proxy1.AddDepartment(args);
                return(returnItem);
            }
        }
 public Department AddDepartment([FromBody] DepartmentAddEditArgs args)
 {
     try
     {
         Department         returnItem = null;
         IDepartmentManager con        = this.ForwardRequestToDepartmentManager;
         returnItem = con.AddDepartment(args);
         return(returnItem);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
 public Department AddDepartment(DepartmentAddEditArgs args)
 {
     try
     {
         Department         returnItem = null;
         IDepartmentManager con        = this.ForwardRequestToDepartmentManager;
         returnItem = con.AddDepartment(args);
         return(returnItem);
     }
     catch (Exception ex)
     {
         ExceptionDetail detail = new ExceptionDetail(ex);
         throw new FaultException <ExceptionDetail>(detail, ex.Message);
     }
 }
        /// <summary>
        /// Creator: Jordan Lindo
        /// Created: 2/15/2020
        /// Approver: Alex Diers
        ///
        /// This button click listener sends the data for creating a new department record to the logic layer
        /// </summary>
        /// <remarks>
        /// Updater: NA
        /// Updated: NA
        /// Update: NA
        ///
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddDepartmentSave_Click(object sender, RoutedEventArgs e)
        {
            string departmentID = txtAddDepartmentDepartmentName.Text;
            string description  = txtAddDepartmentDescription.Text;

            if (ValidateERole.checkDepartmentID(departmentID) && ValidateERole.checkDescription(description))
            {
                try
                {
                    if (_departmentManager.AddDepartment(departmentID, description))
                    {
                        ShiftTimeManager _shiftTimeManger = new ShiftTimeManager();
                        try
                        {
                            foreach (PetUniverseShiftTime shiftTime in DEFAULT_SHIFTTIMES)
                            {
                                shiftTime.DepartmentID = departmentID;
                                _shiftTimeManger.AddShiftTime(shiftTime);
                            }
                        }
                        catch (Exception ex)
                        {
                            WPFErrorHandler.ErrorMessage("failed to save departments Default Shift Times. " + ex.Message);
                        }

                        WPFErrorHandler.SuccessMessage("Department added, with default shift times");
                        canAddDepartment.Visibility  = Visibility.Hidden;
                        canDepartmentList.Visibility = Visibility.Visible;
                        showDGDepartments();
                    }
                    else
                    {
                        WPFErrorHandler.ErrorMessage("Department not added.");
                    }
                }
                catch (Exception ex)
                {
                    WPFErrorHandler.ErrorMessage("Department failed to save. " + ex.Message);
                }
            }
예제 #6
0
        public static void Main(string[] args)
        {
            try
            {
                System.Threading.Thread.Sleep(1000);

                UnityContainer container = new UnityContainer();
                container.LoadConfiguration();

                IDepartmentManager man = container.Resolve <IDepartmentManager>();

                DepartmentAllWrapper deptAllWrapper = man.GetDepartmentAllWrapper();
                ShowDepartmentAllWrapper(deptAllWrapper);

                if (null != deptAllWrapper)
                {
                    if (null != deptAllWrapper.Departments)
                    {
                        Department foundDept1 = deptAllWrapper.Departments.FirstOrDefault();
                        if (null != foundDept1)
                        {
                            DepartmentGetSingleArgs args1 = new DepartmentGetSingleArgs();
                            args1.DepartmentSurrogateKey = foundDept1.DepartmentUUID;
                            DepartmentAddEditSingleWrapper singleWrapper = man.GetDepartmentAddEditSingleWrapper(args1);
                            ShowDepartmentAddEditSingleWrapper(singleWrapper);
                        }
                    }
                }

                DepartmentAddEditArgs newArgs = new DepartmentAddEditArgs();
                newArgs.DepartmentSurrogateKey = Guid.NewGuid();
                newArgs.DepartmentName         = "New_WebApi_Department:" + Guid.NewGuid().ToString("N");
                newArgs.CreateDate             = DateTime.Now;
                Department newDept = man.AddDepartment(newArgs);
                ShowDepartment(newDept);

                if (null != newArgs)
                {
                    DepartmentAddEditArgs updateArgs = new DepartmentAddEditArgs()
                    {
                        DepartmentSurrogateKey = newArgs.DepartmentSurrogateKey, DepartmentName = "Update+" + newArgs.DepartmentName, CreateDate = DateTime.Now
                    };
                    Department dept2 = man.UpdateDepartment(updateArgs);
                    ShowDepartment(dept2);
                    Console.WriteLine(string.Empty);
                }
            }
            catch (Exception ex)
            {
                Exception exc = ex;
                while (null != exc)
                {
                    Console.WriteLine(exc.Message);
                    exc = exc.InnerException;
                }
            }
            finally
            {
                Console.WriteLine("Press ENTER to Exit");
                Console.ReadLine();
            }
        }