Beispiel #1
0
        public JsonResult Create(string loan)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Loan loanObj = JsonConvert.DeserializeObject <Loan>(loan);
                    loanObj.CreatedBy   = "admin";
                    loanObj.CreatedDate = DateTime.Now;
                    loanObj.LastUpdBy   = "admin";
                    loanObj.LastUpdDate = DateTime.Now;
                    loanObj.CompanyId   = "ABC";

                    // TODO: Add update logic here
                    //_context.Update(user);
                    _context.Add(loanObj);
                    _context.SaveChanges();
                }

                return(Json(new { Success = true }));
            }
            catch
            {
                throw;
            }
        }
Beispiel #2
0
        public JsonResult UpdateEmployeePersonal(string employee)
        {
            try
            {
                // TODO: Add update logic here

                if (ModelState.IsValid)
                {
                    Employee employeeObj      = JsonConvert.DeserializeObject <Employee>(employee);
                    var      employeeToUpdate = _context.Employee.Where(e => e.EmployeeId.Trim() == employeeObj.EmployeeId.Trim()).FirstOrDefault();
                    employeeObj.CompanyId   = HttpContext.Session.GetString("CompanyId");
                    employeeObj.CreatedBy   = "admin";
                    employeeObj.CreatedDate = DateTime.Now;
                    employeeObj.LastUpdBy   = "admin";
                    employeeObj.LastUpdDate = DateTime.Now;
                    _context.Entry(employeeToUpdate).CurrentValues.SetValues(employeeObj);
                    _context.SaveChanges();
                }

                return(Json(new { Success = true }));
            }
            catch
            {
                throw;
            }
        }
        public static Responses Update(EmployeeViewModel entity)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    if (entity.Id != 0)
                    {
                        Employee division = db.Employee.Where(o => o.Id == entity.Id).FirstOrDefault();
                        if (division != null)
                        {
                            division.BadgeId       = entity.BadgeId;
                            division.JobPositionId = entity.JobPositionId;
                            division.FirstName     = entity.FirstName;
                            division.MiddleName    = entity.MiddleName;
                            division.LastName      = entity.LastName;
                            division.Address       = entity.Address;
                            division.DateOfHire    = entity.DateOfHire;
                            division.DateOfResign  = entity.DateOfResign;
                            division.PlaceOfBirth  = entity.PlaceOfBirth;
                            division.DateOfBirth   = entity.DateOfBirth;
                            division.Gender        = entity.Gender;
                            division.IsActivated   = entity.IsActivated;
                            division.ModifyBy      = "Asyam";
                            division.ModifyDate    = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        Employee division = new Employee();
                        division.BadgeId       = entity.BadgeId;
                        division.JobPositionId = entity.JobPositionId;
                        division.FirstName     = entity.FirstName;
                        division.MiddleName    = entity.MiddleName;
                        division.LastName      = entity.LastName;
                        division.Address       = entity.Address;
                        division.DateOfHire    = entity.DateOfHire;
                        division.DateOfResign  = entity.DateOfResign;
                        division.PlaceOfBirth  = entity.PlaceOfBirth;
                        division.DateOfBirth   = entity.DateOfBirth;
                        division.Gender        = entity.Gender;
                        division.IsActivated   = entity.IsActivated;
                        division.CreateBy      = "Asyam";
                        division.CreateDate    = DateTime.Now;
                        db.Employee.Add(division);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
        public ActionResult Create([Bind(Include = "SalaryGradeID,Salary,Grade")] SalaryGrade salarygrade)
        {
            if (ModelState.IsValid)
            {
                db.SalaryGrades.Add(salarygrade);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(salarygrade));
        }
Beispiel #5
0
        public T Add(T entity)
        {
            _dbSet.Add(entity);

            if (!_sharedContext)
            {
                _context.SaveChanges();
            }

            return(entity);
        }
        public ActionResult Create([Bind(Include = "EmployeeID,FirstName,Lastname,SalaryGradeID,DOB")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SalaryGradeID = new SelectList(db.SalaryGrades, "SalaryGradeID", "Grade", employee.SalaryGradeID);
            return(View(employee));
        }
        public ActionResult Create([Bind(Include = "WorkId,TimeIn,TimeOut,WorkDate,EmployeeID")] Work work)
        {
            if (ModelState.IsValid)
            {
                db.Works.Add(work);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "FirstName", work.EmployeeID);
            return(View(work));
        }
        public ActionResult Create([Bind(Include = "LocationID,Location,WorkID,EmployeeID")] WorkLocation worklocation)
        {
            if (ModelState.IsValid)
            {
                db.WorkLocations.Add(worklocation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "FirstName", worklocation.EmployeeID);
            ViewBag.WorkID     = new SelectList(db.Works, "WorkId", "WorkId", worklocation.WorkID);
            return(View(worklocation));
        }
Beispiel #9
0
        public virtual T Add(T entity)
        {
            entity.CreateDate = DateTime.Now;

            DbSet.Add(entity);

            if (!_sharedContext)
            {
                _context.SaveChanges();
            }

            return(entity);
        }
Beispiel #10
0
        public void Seed()
        {
            if (_context.Employees.Count() > 0)
            {
                return;
            }

            SeedBenefitPlans();
            SeedPayCycles();
            SeedRelationships();
            SeedEmployees();

            _context.SaveChanges();
        }
        //save payroll
        public static Responses SaveSalary(List <EmployeeSalaryViewModel> entities)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    foreach (var item in entities)
                    {
                        EmployeeSalary es = db.EmployeeSalary
                                            .Where(o => o.PayrollPeriodId == item.PayrollPeriodId &&
                                                   o.BadgeId == item.BadgeId &&
                                                   o.SalaryComponentId == item.SalaryComponentId)
                                            .FirstOrDefault();

                        if (es == null)
                        {
                            EmployeeSalary newEs = new EmployeeSalary();
                            newEs.PayrollPeriodId   = item.PayrollPeriodId;
                            newEs.SalaryComponentId = item.SalaryComponentId;
                            newEs.BadgeId           = item.BadgeId;
                            newEs.BasicValue        = item.BasicValue;

                            newEs.CreateBy   = "Sol";
                            newEs.CreateDate = DateTime.Now;

                            db.EmployeeSalary.Add(newEs);
                            db.SaveChanges();
                        }

                        else
                        {
                            es.BasicValue = item.BasicValue;
                            es.ModifyBy   = "Sol";
                            es.ModifyDate = DateTime.Now;

                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
Beispiel #12
0
        private void AddNewEmployees(DataTable dt, PayrollContext context)
        {
            DataView dv = new DataView(dt);

            dv.Sort = COL_EMPID;
            DataTable distinctEmployees = dv.ToTable(true, COL_EMPID);

            context.Database.EnsureCreated();
            var employeedToAdd = new List <Employee>();

            foreach (DataRow dr in distinctEmployees.Rows)
            {
                var employeeId = int.Parse(dr[COL_EMPID].ToString());

                if (context.Employee.FirstOrDefault(e => e.EmployeeId == employeeId) == null)
                {
                    employeedToAdd.Add(new Employee {
                        EmployeeId = employeeId
                    });
                }
            }

            if (employeedToAdd.Count > 0)
            {
                context.Employee.AddRange(employeedToAdd.ToArray());
                context.SaveChanges();
            }
        }
 public ActionResult UploadData()
 {
     try
     {
         var            ListName = (List <DownloadDataViewModel>)Session["SessionName"];
         PayrollContext db       = new PayrollContext();
         foreach (var item in ListName)
         {
             UploadData up = new UploadData();
             up.Dn         = Convert.ToInt32(item.DN);
             up.Din        = Convert.ToInt32(item.DIN);
             up.Type       = item.Type;
             up.Mode       = item.mode;
             up.Clock      = Convert.ToDateTime(item.Clock);
             up.DateUpload = DateTime.Now;
             db.UploadDatas.Add(up);
             db.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(View("ConnectBiometric"));
 }
Beispiel #14
0
        private string ExtractAndValidateReportId(DataTable dt, PayrollContext context, out int reportId)
        {
            string errorString = string.Empty;

            // Extract report id
            reportId = int.Parse(dt.Rows[dt.Rows.Count - 1][COL_HOURSWORKED].ToString());
            dt.Rows.RemoveAt(dt.Rows.Count - 1);
            dt.AcceptChanges();

            int id     = reportId;
            var report = context.Report.FirstOrDefault(r => r.ReportId == id);

            if (report == null)
            {
                context.Report.Add(new Report {
                    ReportId = id
                });
                context.SaveChanges();
            }
            else
            {
                errorString = string.Format("Report with ID: {0} already exists in database.", reportId);
            }

            return(errorString);
        }
Beispiel #15
0
        public static void Initialize(PayrollContext context)
        {
            context.Database.EnsureCreated();

            if (context.Payroll.Any())
            {
                return;
            }

            if (!context.Job.Any())
            {
                var jobs = new Job[]
                {
                    new Job {
                        JobCode = "A", HourlyRate = 20
                    },
                    new Job {
                        JobCode = "B", HourlyRate = 30
                    }
                };

                context.Job.AddRange(jobs);
                context.SaveChanges();
            }
        }
Beispiel #16
0
        public static Responses Update(SellingDetailViewModel entity)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    if (entity.Id != 0)
                    {
                        SellingDetail sd = db.SellingDetail.Where(o => o.Id == entity.Id).FirstOrDefault();
                        if (sd != null)
                        {
                            sd.SellingHeaderId = entity.SellingHeaderId;
                            sd.ItemId          = entity.ItemId;
                            sd.Quantity        = entity.Quantity;
                            sd.Price           = entity.Price;
                            sd.Amount          = entity.Amount;
                            sd.IsActivated     = entity.IsActivated;
                            sd.ModifiedBy      = "Ryan";
                            sd.ModifiedDate    = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        SellingDetail sd = new SellingDetail();
                        sd.SellingHeaderId = entity.SellingHeaderId;
                        sd.ItemId          = entity.ItemId;
                        sd.Quantity        = entity.Quantity;
                        sd.Price           = entity.Price;
                        sd.Amount          = entity.Amount;
                        sd.IsActivated     = entity.IsActivated;
                        sd.CreatedBy       = "Ryan";
                        sd.CreatedDate     = DateTime.Now;
                        db.SellingDetail.Add(sd);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
        public static Responses Update(PayrollPeriodViewModel entity)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    if (entity.Id != 0)
                    {
                        PayrollPeriod period = db.PayrollPeriod.Where(o => o.Id == entity.Id).FirstOrDefault();
                        if (period != null)
                        {
                            period.PeriodYear      = entity.PeriodYear;
                            period.PeriodMonth     = entity.PeriodMonth;
                            period.BeginDate       = entity.BeginDate;
                            period.EndDate         = entity.EndDate;
                            period.IsCurrentPeriod = entity.IsCurentPeriod;
                            period.IsActivated     = entity.IsActivated;
                            period.ModifyBy        = "Asyam";
                            period.ModifyDate      = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        PayrollPeriod period = new PayrollPeriod();
                        period.PeriodYear      = entity.PeriodYear;
                        period.PeriodMonth     = entity.PeriodMonth;
                        period.BeginDate       = entity.BeginDate;
                        period.EndDate         = entity.EndDate;
                        period.IsCurrentPeriod = entity.IsCurentPeriod;
                        period.IsActivated     = entity.IsActivated;
                        period.CreateBy        = "Asyam";
                        period.CreateDate      = DateTime.Now;
                        db.PayrollPeriod.Add(period);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
        public static Responses Update(EmployeeSalaryViewModel entity)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    if (entity.Id != 0)
                    {
                        EmployeeSalary employeesalary = db.EmployeeSalary.Where(o => o.Id == entity.Id).FirstOrDefault();
                        if (employeesalary != null)
                        {
                            employeesalary.BadgeId           = entity.BadgeId;
                            employeesalary.PayrollPeriodId   = entity.PayrollPeriodId;
                            employeesalary.SalaryComponentId = entity.SalaryComponentId;
                            employeesalary.BasicValue        = entity.BasicValue;
                            employeesalary.FinalValue        = entity.FinalValue;
                            employeesalary.IsActivated       = entity.IsActivated;
                            employeesalary.ModifyBy          = "Azam";
                            employeesalary.ModifyDate        = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        EmployeeSalary employeesalary = new EmployeeSalary();
                        employeesalary.BadgeId           = entity.BadgeId;
                        employeesalary.PayrollPeriodId   = entity.PayrollPeriodId;
                        employeesalary.SalaryComponentId = entity.SalaryComponentId;
                        employeesalary.BasicValue        = entity.BasicValue;
                        employeesalary.FinalValue        = entity.FinalValue;
                        employeesalary.IsActivated       = entity.IsActivated;
                        employeesalary.CreateBy          = "Azam";
                        employeesalary.CreateDate        = DateTime.Now;
                        db.EmployeeSalary.Add(employeesalary);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
Beispiel #19
0
        public static Responses Update(SalaryComponentViewModel entity)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    if (entity.Id != 0)
                    {
                        SalaryComponent salarycomponent = db.SalaryComponent.Where(o => o.Id == entity.Id).FirstOrDefault();
                        if (salarycomponent != null)
                        {
                            salarycomponent.Code         = entity.Code;
                            salarycomponent.Description  = entity.Description;
                            salarycomponent.Period       = entity.Period;
                            salarycomponent.Type         = entity.Type;
                            salarycomponent.IsActivated  = entity.IsActivated;
                            salarycomponent.ModifiedBy   = "Ryan";
                            salarycomponent.ModifiedDate = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        SalaryComponent salarycomponent = new SalaryComponent();
                        salarycomponent.Code        = entity.Code;
                        salarycomponent.Description = entity.Description;
                        salarycomponent.Period      = entity.Period;
                        salarycomponent.Type        = entity.Type;
                        salarycomponent.IsActivated = entity.IsActivated;
                        salarycomponent.CreatedBy   = "Ryan";
                        salarycomponent.CreatedDate = DateTime.Now;
                        db.SalaryComponent.Add(salarycomponent);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
        public static Responses Update(SellingHeaderViewModel entity)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    if (entity.Id != 0)
                    {
                        SellingHeader sh = db.SellingHeader.Where(o => o.Id == entity.Id).FirstOrDefault();
                        if (sh != null)
                        {
                            sh.Reference     = entity.Reference;
                            sh.DateOfSelling = entity.DateOfSelling;
                            sh.SellingTotal  = entity.SellingTotal;
                            sh.Payment       = entity.Payment;
                            sh.IsActivated   = entity.IsActivated;
                            sh.ModifyBy      = "Sol";
                            sh.ModifyDate    = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        SellingHeader sh = new SellingHeader();
                        sh.Reference     = entity.Reference;
                        sh.DateOfSelling = entity.DateOfSelling;
                        sh.SellingTotal  = entity.SellingTotal;
                        sh.Payment       = entity.Payment;
                        sh.IsActivated   = entity.IsActivated;
                        sh.CreateBy      = "Sol";
                        sh.CreateDate    = DateTime.Now;
                        db.SellingHeader.Add(sh);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
Beispiel #21
0
        public static Responses Update(SalaryComponentViewModel entity)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    if (entity.Id != 0)
                    {
                        SalaryComponent division = db.SalaryComponent.Where(o => o.Id == entity.Id).FirstOrDefault();
                        if (division != null)
                        {
                            division.Code        = entity.Code;
                            division.Description = entity.Description;
                            division.Period      = entity.Period;
                            division.Type        = entity.Type;
                            division.IsActivated = entity.IsActivated;
                            division.ModifyBy    = "Asyam";
                            division.ModifyDate  = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        SalaryComponent division = new SalaryComponent();
                        division.Code        = entity.Code;
                        division.Description = entity.Description;
                        division.Period      = entity.Period;
                        division.Type        = entity.Type;
                        division.IsActivated = entity.IsActivated;
                        division.CreateBy    = "Asyam";
                        division.CreateDate  = DateTime.Now;
                        db.SalaryComponent.Add(division);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
Beispiel #22
0
        public static Responses Update(ItemViewModel entity)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    if (entity.Id != 0)
                    {
                        Item item = db.Item.Where(o => o.Id == entity.Id).FirstOrDefault();
                        if (item != null)
                        {
                            item.Code        = entity.Code;
                            item.Description = entity.Description;
                            item.Price       = entity.Price;
                            item.Stock       = entity.Stock;
                            item.IsActivated = entity.IsActivated;
                            item.ModifyBy    = "Azam";
                            item.ModifyDate  = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        Item item = new Item();
                        item.Code        = entity.Code;
                        item.Description = entity.Description;
                        item.Price       = entity.Price;
                        item.Stock       = entity.Stock;
                        item.IsActivated = entity.IsActivated;
                        item.CreateBy    = "Azam";
                        item.CreateDate  = DateTime.Now;
                        db.Item.Add(item);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
        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);
        }
        public static Responses Update(AttendanceViewModel entity)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    if (entity.Id != 0)
                    {
                        Attendance attendance = db.Attendance.Where(o => o.Id == entity.Id).FirstOrDefault();
                        if (attendance != null)
                        {
                            attendance.BadgeId     = entity.BadgeId;
                            attendance.CheckIn     = entity.CheckIn;
                            attendance.CheckOut    = entity.CheckOut;
                            attendance.IsActivated = entity.IsActivated;
                            attendance.ModifyBy    = "Asyam";
                            attendance.ModifyDate  = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        Attendance attendance = new Attendance();
                        attendance.BadgeId     = entity.BadgeId;
                        attendance.CheckIn     = entity.CheckIn;
                        attendance.CheckOut    = entity.CheckOut;
                        attendance.IsActivated = entity.IsActivated;
                        attendance.CreateBy    = "Asyam";
                        attendance.CreateDate  = DateTime.Now;
                        db.Attendance.Add(attendance);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
Beispiel #25
0
        public static Responses Update(DepartmentViewModel entity)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    if (entity.Id != 0)
                    {
                        Department department = db.Department.Where(o => o.Id == entity.Id).FirstOrDefault();
                        if (department != null)
                        {
                            department.Code         = entity.Code;
                            department.DivisionId   = entity.DivisionId;
                            department.Description  = entity.Description;
                            department.IsActivated  = entity.IsActivated;
                            department.ModifiedBy   = "Ryan";
                            department.ModifiedDate = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        Department department = new Department();
                        department.Code        = entity.Code;
                        department.DivisionId  = entity.DivisionId;
                        department.Description = entity.Description;
                        department.IsActivated = entity.IsActivated;
                        department.CreatedBy   = "Ryan";
                        department.CreatedDate = DateTime.Now;
                        db.Department.Add(department);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
Beispiel #26
0
        public static Responses Update(JobPositionViewModel entity)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    if (entity.Id != 0)
                    {
                        JobPosition jobposition = db.JobPosition.Where(o => o.Id == entity.Id).FirstOrDefault();
                        if (jobposition != null)
                        {
                            jobposition.Code         = entity.Code;
                            jobposition.DepartmentId = entity.DepartmentId;
                            jobposition.Description  = entity.Description;
                            jobposition.IsActivated  = entity.IsActivated;
                            jobposition.ModifyBy     = "Azam";
                            jobposition.ModifyDate   = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        JobPosition jobposition = new JobPosition();
                        jobposition.Code         = entity.Code;
                        jobposition.DepartmentId = entity.DepartmentId;
                        jobposition.Description  = entity.Description;
                        jobposition.IsActivated  = entity.IsActivated;
                        jobposition.CreateBy     = "Azam";
                        jobposition.CreateDate   = DateTime.Now;
                        db.JobPosition.Add(jobposition);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
Beispiel #27
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);
        }
Beispiel #28
0
        public static void InsertPaychecks(PayrollContext context)
        {
            var query = context.Employees.ToList();

            foreach (var employee in query)
            {
                var paycheckList = GeneratePaycheck.GeneratePaycheckList(employee);
                employee.PaycheckHistory.AddRange(paycheckList);
            }
            context.SaveChanges();
        }
        public static void InsertEmployees(List <Employee> employees, PayrollContext context)
        {
            var departments = context.Departments.ToList();

            foreach (var employee in employees)
            {
                int id = departments.Where(d => d.Name == employee.Department).First().Id;
                employee.DepartmentId = id;
            }
            context.AddRange(employees);
            context.SaveChanges();
        }
        private void InsertCountry()
        {
            using (var context = new PayrollContext(IntergrationTestsSetup.ContextOptions))
            {
                var country = new Country {
                    Name = "South Africa", Code = "ZAR"
                };

                context.Country.Add(country);
                context.SaveChanges();
            }
        }