コード例 #1
0
        public IActionResult Save(DepartmentIndexViewModel model)
        {
            var UserId = HttpContext.Session.GetString("UserId");

            if (ModelState.IsValid)
            {
                var department = new Department
                {
                    Id          = model.Id,
                    Description = model.Description,
                };
                if (model.Id.ToString().Equals("0"))
                {
                    department.CreatedBy    = UserId;
                    department.CreationDate = DateTime.Now;
                    _Department.Add(department);
                }
                else
                {
                    department.ModifiedBy   = UserId;
                    department.ModifiedDate = DateTime.Now;
                    _Department.Update(department);
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Index", model));
            }
        }
コード例 #2
0
 public IActionResult Create(Department model)
 {
     if (ModelState.IsValid)
     {
         _Department.Add(model);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
コード例 #3
0
 public IActionResult create(Department dep)
 {
     if (ModelState.IsValid)
     {
         Department department = _departmentrepository.Add(dep);
         return(RedirectToAction("index", new { id = dep.Id }));
     }
     return(View());
 }
コード例 #4
0
 public int AddDepartment(DepartmentRequest model)
 {
     try
     {
         return(_departmentManager.Add(model));
     }
     catch (Exception ex)
     {
         throw new TpoBaseException(ex.Message);
     }
 }
コード例 #5
0
 public IActionResult Create(Department department)
 {
     if (ModelState.IsValid)
     {
         _department.Add(department);
         return(View("Thank", department));
     }
     else
     {
         return(View());
     }
 }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Department department)
        {
            department.CreatedDate  = DateTime.UtcNow.Date;
            department.ModifiedDate = DateTime.UtcNow.Date;
            if (ModelState.IsValid)
            {
                if (dep.IfExists(department.Name) != true)
                {
                    dep.Add(department);
                    await dep.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            return(View(department));
        }
コード例 #7
0
        public async Task Add_Department()
        {
            IDepartment dep = GetInMemoryRepository();
            Department  o   = new Department()
            {
                Id           = 1,
                Name         = "Lit",
                CreatedDate  = DateTime.UtcNow,
                ModifiedDate = DateTime.UtcNow
            };

            dep.Add(o);
            await dep.SaveChangesAsync();

            int x = await dep.CountDepartmentAsync();

            Assert.Equal(1, x);
        }
コード例 #8
0
 public IActionResult OnPost()
 {
     if (!ModelState.IsValid)
     {
         DepartmentVM.Faculty = _facultyRepo.GetFacultyListOfDropDown();
         return Page();
     }
     if (DepartmentVM.Department.Id == 0)
     {
         _deptRepo.Add(DepartmentVM.Department);
     }
     else
     {
         _deptRepo.Update(DepartmentVM.Department);
     }
     _deptRepo.Save();
     return RedirectToPage("./Index");
 }
コード例 #9
0
 private bool  addDepartment(department dp)
 {
     try
     {
         dp.departmentName = this.tbox_depart.Text.Trim();
         department d = cb_parentdep.SelectedItem as department;
         if (d == null || d.guid == null)
         {
             dp.parentDepartment = "";
         }
         else
         {
             dp.parentDepartment = d.guid;
         }
         dp.guid = Guid.NewGuid().ToString();
         return(_department.Add(dp));
     }
     catch { return(false); }
 }
コード例 #10
0
        public ActionResult Create(Department department)
        {
            if (getCurrentUser() == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else
            {
                try
                {
                    department.d_active_yn = "Y";
                    department.d_cre_by    = 12;
                    department.d_cre_date  = DateTime.Now;
                    idepartment.Add(department);

                    return(RedirectToAction(nameof(Index)));
                }
                catch
                {
                    return(View());
                }
            }
        }
コード例 #11
0
 public IActionResult Save(DepartmentViewModel model)
 {
     if (ModelState.IsValid)
     {
         var department = new Department
         {
             Id          = model.Id,
             Description = model.Description,
         };
         if (model.Id.ToString().Length <= 0)
         {
             _Department.Add(department);
         }
         else
         {
             _Department.Update(department);
         }
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
コード例 #12
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(WSS.Model.Department model)
 {
     return(dal.Add(model));
 }
コード例 #13
0
 bool  Add(department d)
 {
     return(Department.Add(d));
 }
コード例 #14
0
ファイル: BDepartment.cs プロジェクト: zhr008/ERP-1
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(BaseDepartmentTable model)
 {
     return(dal.Add(model));
 }