コード例 #1
0
        public PositionViewModel ViewPositionDetails(int positionId)
        {
            var singlePositionDetail = entity.tblEmployeePositions.Where(x => x.positionId == positionId).FirstOrDefault();
            PositionViewModel modelObj = new PositionViewModel()
            {
                positionId = singlePositionDetail.positionId,
                positionName = singlePositionDetail.positionName,
                positionDescription = singlePositionDetail.positionDescription

            };
            return modelObj;

        }
コード例 #2
0
        public void AddNewPosition(PositionViewModel positionModel)
        {
            tblEmployeePosition newPosition = new tblEmployeePosition()
            {
                positionId=positionModel.positionId,
                positionDescription=positionModel.positionDescription,
                positionName=positionModel.positionName

            };
            entity.tblEmployeePositions.Add(newPosition);
            entity.SaveChanges();

        }
コード例 #3
0
        public void EditPosition(PositionViewModel positionModel)
        {
            tblEmployeePosition newPosition = new tblEmployeePosition()
            {
                positionId = positionModel.positionId,
                positionDescription = positionModel.positionDescription,
                positionName = positionModel.positionName

            };
            entity.tblEmployeePositions.Add(newPosition);
            entity.Entry(newPosition).State = EntityState.Modified;
            entity.SaveChanges();


        }
コード例 #4
0
 public ActionResult Create(FormCollection collection,PositionViewModel modelObj)
 {
     if (HttpContext.Session["UserId"] == null)
     {
         return RedirectToAction("Login", "Login");
     }
     
     try
     {
         // TODO: Add insert logic here
         positionRepo.AddNewPosition(modelObj);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
コード例 #5
0
        public List<PositionViewModel> PositionList()
        {
            var positionList = entity.tblEmployeePositions.ToList();
            List<PositionViewModel> positionModelList = new List<PositionViewModel>();
            foreach(var positionItem in positionList)
            {
                PositionViewModel modelObj = new PositionViewModel()
                {
                    positionId=positionItem.positionId,
                    positionDescription=positionItem.positionDescription,
                    positionName=positionItem.positionName

                };
                positionModelList.Add(modelObj);

            }
            return positionModelList;

        }
コード例 #6
0
 public ActionResult Edit(int id, PositionViewModel modelObj)
 {
     if (HttpContext.Session["UserId"] == null)
     {
         return RedirectToAction("Login", "Login");
     }
     
     try
     {
         // TODO: Add update logic here
         positionRepo.EditPosition(modelObj);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }