示例#1
0
        public static SalaryDefaultValueViewModel GetById(int id)
        {
            SalaryDefaultValueViewModel result = new SalaryDefaultValueViewModel();

            using (var db = new PayrollContext())
            {
                result = (from d in db.SalaryDefaultValue
                          join jp in db.JobPosition on
                          d.JobPositionId equals jp.Id
                          join sc in db.SalaryComponent on
                          d.SalaryComponentId equals sc.Id
                          where d.Id == id
                          select new SalaryDefaultValueViewModel
                {
                    Id = d.Id,
                    JobName = jp.Description,
                    JobPositionId = d.JobPositionId,
                    SalaryComponentName = sc.Description,
                    SalaryComponentId = d.SalaryComponentId,
                    Value = d.Value,
                    IsActivated = d.IsActivated
                }).FirstOrDefault();
            }
            return(result);
        }
        public static SalaryDefaultValueViewModel GetById(int id)
        {
            SalaryDefaultValueViewModel result = new SalaryDefaultValueViewModel();

            using (var db = new PayrollContext())
            {
                result = (from d in db.SalaryDefaultValue
                          join div in db.JobPosition on
                          d.JobPositionId equals div.Id
                          join com in db.SalaryComponent on
                          d.SalaryComponentId equals com.Id
                          select new SalaryDefaultValueViewModel
                {
                    Id = d.Id,
                    JobPositionId = d.JobPositionId,
                    JobPositionName = div.Description,
                    SalaryComponentId = d.SalaryComponentId,
                    SalaryComponentName = com.Description,
                    Value = d.Value,
                    IsActivated = d.IsActivated
                }
                          ).FirstOrDefault();
            }
            return(result);
        }
示例#3
0
        public ActionResult GetSalaryComponent(int jobPositionId, int salaryComponentId)
        {
            EmployeeSalaryViewModel     model = EmployeeSalaryRepo.GetByComponentId(salaryComponentId);
            SalaryDefaultValueViewModel sd    = SalaryDefaultValueRepo.GetByJobPosition(jobPositionId, salaryComponentId);

            if (sd != null)
            {
                model.BasicValue = sd.Value;
            }
            return(PartialView("_GetSalaryComponent", model));
        }
        public ActionResult Edit(SalaryDefaultValueViewModel model)
        {
            Responses responses = SalaryDefaultValueRepo.Update(model);

            if (responses.Success)
            {
                return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { success = false, message = responses.Message }, JsonRequestBehavior.AllowGet));
            }
        }
        public static SalaryDefaultValueViewModel GetByJobPosition(int jobPositionId, int salaryComponentId)
        {
            SalaryDefaultValueViewModel result = new SalaryDefaultValueViewModel();

            using (var db = new PayrollContext())
            {
                result = db.SalaryDefaultValue.Where(o => o.JobPositionId == jobPositionId && o.SalaryComponentId == salaryComponentId).Select(o => new SalaryDefaultValueViewModel {
                    Id                = o.Id,
                    JobPositionId     = o.JobPositionId,
                    SalaryComponentId = o.SalaryComponentId,
                    Value             = o.Value
                }).FirstOrDefault();
            }
            return(result);
        }
 public ActionResult Edit(SalaryDefaultValueViewModel model)
 {
     if (ModelState.IsValid)
     {
         Responses responses = SalaryDefaultValueRepo.Update(model);
         if (responses.Success)
         {
             return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { success = false, message = "Error msg" }, JsonRequestBehavior.AllowGet));
         }
     }
     return(Json(new { success = false, message = "Invalid" }, JsonRequestBehavior.AllowGet));
 }
        public static Responses Update(SalaryDefaultValueViewModel entity)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    if (entity.Id != 0)
                    {
                        SalaryDefaultValue division = db.SalaryDefaultValue.Where(o => o.Id == entity.Id).FirstOrDefault();
                        if (division != null)
                        {
                            division.JobPositionId     = entity.JobPositionId;
                            division.SalaryComponentId = entity.SalaryComponentId;
                            division.Value             = entity.Value;
                            division.IsActivated       = entity.IsActivated;
                            division.ModifiedBy        = "Ryan";
                            division.ModifiedDate      = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        SalaryDefaultValue division = new SalaryDefaultValue();

                        division.JobPositionId     = entity.JobPositionId;
                        division.SalaryComponentId = entity.SalaryComponentId;
                        division.Value             = entity.Value;
                        division.IsActivated       = entity.IsActivated;
                        division.CreatedBy         = "Ryan";
                        division.CreatedDate       = DateTime.Now;
                        db.SalaryDefaultValue.Add(division);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
示例#8
0
        public static Responses Update(SalaryDefaultValueViewModel entity)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    if (entity.Id != 0)
                    {
                        SalaryDefaultValue sdv = db.SalaryDefaultValue.Where(o => o.Id == entity.Id).FirstOrDefault();
                        if (sdv != null)
                        {
                            sdv.JobPositionId     = entity.JobPositionId;
                            sdv.SalaryComponentId = entity.SalaryComponentId;
                            sdv.Value             = entity.Value;
                            sdv.IsActivated       = entity.IsActivated;
                            sdv.ModifyBy          = "Azam";
                            sdv.ModifyDate        = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        SalaryDefaultValue sdv = new SalaryDefaultValue();
                        sdv.JobPositionId     = entity.JobPositionId;
                        sdv.SalaryComponentId = entity.SalaryComponentId;
                        sdv.Value             = entity.Value;
                        sdv.IsActivated       = entity.IsActivated;
                        sdv.CreateBy          = "Azam";
                        sdv.CreateDate        = DateTime.Now;
                        db.SalaryDefaultValue.Add(sdv);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
 // PUT api/<controller>/5
 public Responses Put(int id, [FromBody] SalaryDefaultValueViewModel entity)
 {
     entity.Id = id;
     return(SalaryDefaultValueRepo.Update(entity));
 }
 // POST api/<controller>
 public Responses Post([FromBody] SalaryDefaultValueViewModel entity)
 {
     return(SalaryDefaultValueRepo.Update(entity));
 }