コード例 #1
0
 public void SaveItem(DelegationItem item)
 {
     using (var dbContext = new DelegationContext())
     {
         dbContext.DelegationItems.Add(item);
         dbContext.SaveChanges();
     }
 }
コード例 #2
0
        public ActionResult Create()
        {
            var model = new DelegationItem();

            model.MainMenu     = _mainMenu;
            model.CurrentLogin = CurrentUser;
            model.DateFrom     = DateTime.Today;
            model.DateTo       = DateTime.Today;
            return(View(model));
        }
コード例 #3
0
        public ActionResult Post(DelegationItem item)
        {
            if (String.IsNullOrWhiteSpace(item.FirstName))
            {
                return(BadRequest("firstName can't be empty"));
            }

            _delegationItemRepository.SaveItem(item);
            return(Ok());
        }
コード例 #4
0
        public ActionResult Detail(int MstDelegationId)
        {
            var data  = _DelegationBLL.GetDelegationById(MstDelegationId);
            var model = new DelegationItem();

            model              = Mapper.Map <DelegationItem>(data);
            model.MainMenu     = _mainMenu;
            model.CurrentLogin = CurrentUser;
            model.ChangesLogs  = GetChangesHistory((int)Enums.MenuList.MasterDelegation, MstDelegationId);
            return(View(model));
        }
コード例 #5
0
        public ActionResult Edit(int MstDelegationId)
        {
            var data  = _DelegationBLL.GetDelegationById(MstDelegationId);
            var model = new DelegationItem();

            model = Mapper.Map <DelegationItem>(data);
            model.EmployeeFromS = _employeeBLL.GetByID(model.EmployeeFrom).FORMAL_NAME;
            model.EmployeeToS   = _employeeBLL.GetByID(model.EmployeeTo).FORMAL_NAME;
            model.MainMenu      = _mainMenu;
            model.CurrentLogin  = CurrentUser;
            model.ChangesLogs   = GetChangesHistory((int)Enums.MenuList.MasterDelegation, MstDelegationId);
            return(View(model));
        }
コード例 #6
0
        public JsonResult UploadFile(HttpPostedFileBase upload)
        {
            var qtyPacked = string.Empty;
            var qty       = string.Empty;

            var data  = (new ExcelReader()).ReadExcel(upload);
            var model = new List <DelegationItem>();

            if (data != null)
            {
                foreach (var dataRow in data.DataRows)
                {
                    if (dataRow[0] == "")
                    {
                        continue;
                    }
                    var item = new DelegationItem();
                    item.EmployeeFrom  = dataRow[0].ToString();
                    item.EmployeeFromS = dataRow[1].ToString();
                    item.EmployeeTo    = dataRow[2].ToString();
                    item.EmployeeToS   = dataRow[3].ToString();
                    double DateFrom = double.Parse(dataRow[4].ToString());
                    double DateTo   = double.Parse(dataRow[5].ToString());
                    item.DateFrom         = DateTime.FromOADate(DateFrom);
                    item.DateTo           = DateTime.FromOADate(DateTo);
                    item.IsComplaintFrom  = Convert.ToBoolean(Convert.ToInt16(dataRow[6]));
                    item.IsComplaintFromS = dataRow[6] == "1"? "True": "False";
                    item.ErrorMessage     = string.Empty;

                    var existEmp   = _employeeBLL.GetByID(dataRow[0]);
                    var existEmpTo = _employeeBLL.GetByID(dataRow[2]);

                    if (existEmp == null)
                    {
                        item.ErrorMessage += "Data Employee ID From Not Exist in master employee,";
                    }
                    if (existEmpTo == null)
                    {
                        item.ErrorMessage += "Data Employee ID To Not Exist in master employee,";
                    }

                    model.Add(item);
                }
            }
            return(Json(model));
        }
コード例 #7
0
 public ActionResult Edit(DelegationItem model, HttpPostedFileBase Attachment)
 {
     if (ModelState.IsValid)
     {
         var data = Mapper.Map <DelegationDto>(model);
         data.ModifiedDate = DateTime.Now;
         data.ModifiedBy   = CurrentUser.USERNAME;
         data.EmployeeFrom = _employeeBLL.GetExist(model.EmployeeFromS).EMPLOYEE_ID;
         data.EmployeeTo   = _employeeBLL.GetExist(model.EmployeeToS).EMPLOYEE_ID;
         if (Attachment != null)
         {
             string filename = System.IO.Path.GetFileName(Attachment.FileName);
             Attachment.SaveAs(Server.MapPath("~/files_upload/" + filename));
             string filepathtosave = "files_upload" + filename;
             data.Attachment = filename;
         }
         _DelegationBLL.Save(data, CurrentUser);
     }
     return(RedirectToAction("Index", "MstDelegation"));
 }