Ejemplo n.º 1
0
        public IActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var employee = _context.Employees.FirstOrDefault(m => m.Id == id);

            if (employee == null)
            {
                return(NotFound());
            }

            foreach (var emp in _context.Employees)
            {
                if (emp.ManagerId == id)
                {
                    emp.ManagerId = 1;
                }
            }
            _context.Employees.Remove(employee);
            _context.SaveChanges();

            return(RedirectToAction("Index"));;
        }
        public ActionResult Delete(int id)
        {
            var obj = context.EmpPromotions.Find(id);

            context.EmpPromotions.Remove(obj);
            context.SaveChanges();
            return(Json("OK"));
        }
Ejemplo n.º 3
0
 public ActionResult Edit(JobTitle job)
 {
     if (ModelState.IsValid)
     {
         context.JobTitles.AddOrUpdate(job);
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(job));
 }
        public ActionResult Create([Bind(Include = "Id,Name,StartDate,EndDate,Status")] Training training)
        {
            if (ModelState.IsValid)
            {
                db.Trainings.Add(training);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(training));
        }
Ejemplo n.º 5
0
 public ActionResult Edit(JobTitle job)
 {
     if (ModelState.IsValid)
     {
         //AddOrUpdate -> using System.Data.Entity.Migrations;
         context.JobTitles.AddOrUpdate(job);
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(job));
 }
Ejemplo n.º 6
0
        public ActionResult Edit(Employee obj)
        {
            if (ModelState.IsValid)
            {
                context.Employees.AddOrUpdate(obj);
                context.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(obj));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Description")] Position position)
        {
            if (ModelState.IsValid)
            {
                db.Positions.Add(position);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(position));
        }
        public ActionResult Delete(int id)
        {
            var job = context.JobTitles.Find(id);

            if (job != null)
            {
                context.JobTitles.Remove(job);
                context.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 9
0
        public ActionResult Create([Bind(Include = "EmployeeId,FirstName,LastName,DateBirthday,INN")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
Ejemplo n.º 10
0
        public JsonResult EnableMenu(string WebMenuAccess, Guid IdRole)
        {
            AccessModels am = new AccessModels();

            am.Id = Guid.NewGuid();
            am.UserAccountRoles_Id      = IdRole;
            am.UserAccountAccess_EnumId = 0;
            am.WebMenuAccess            = WebMenuAccess;
            db.Access.Add(am);
            db.SaveChanges();

            return(Json(new { status = "200" }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 11
0
 public ActionResult Edit(Department d)
 {
     if (ModelState.IsValid)
     {
         Department obj = context1.Departments.Single(x => x.DepartmentID == d.DepartmentID);
         obj.Name         = d.Name;
         obj.GroupName    = d.GroupName;
         obj.ModifiedDate = d.ModifiedDate;
         context1.SaveChanges();
         return(RedirectToAction("Departments"));
     }
     return(View(d));
 }
Ejemplo n.º 12
0
        private static void OnboardEmployee(HrContext hrContext, Person person, DateTime birthDate, string sex, string ssn)
        {
            if (person == null)
            {
                Debug.WriteLine("Person 22781 not found");
            }

            Employee employee = new Employee()
            {
                BusinessEntityId = person.BusinessEntityId,
                BirthDate        = birthDate,
                Gender           = sex,
                NationalIdNumber = ssn,
                LoginId          = string.Format($"adventure-works\\{person.FirstName.ToLower()}.{person.LastName.ToLower()}"),
                JobTitle         = "Software Intern",
                MaritalStatus    = "S",
                HireDate         = DateTime.Today,
                SalariedFlag     = true,
                VacationHours    = 40,
                SickLeaveHours   = 16,
                CurrentFlag      = true
            };

            hrContext.Employee.Add(employee);

            try
            {
                hrContext.SaveChanges();
            }
            catch (Exception e)
            {
                Debug.WriteLine("Exception: " + e.Message);
            }
        }
Ejemplo n.º 13
0
        private static Person CreatePerson(HrContext context, string firstName, string lastName, string personType)
        {
            BusinessEntity be = new BusinessEntity();

            //{
            //    ModifiedDate = DateTime.UtcNow
            //};
            context.BusinessEntity.Add(be);

            Person person = new Person
            {
                BusinessEntityId = be.BusinessEntityId,
                PersonType       = personType,
                FirstName        = firstName,
                LastName         = lastName
            };

            context.Person.Add(person);

            try
            {
                context.SaveChanges();
            }
            catch (Exception e)
            {
                Debug.WriteLine("CreatePerson exception: " + e.Message);
            }
            return(person);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Note note = db.Notes.Find(id);

            db.Notes.Remove(note);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 15
0
        public ActionResult DeleteConfirmed(int id)
        {
            Employee employee = db.Employees.Find(id);

            db.Employees.Remove(employee);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 16
0
        public ActionResult Delete(int id)
        {
            var photoToDel = context.Photos.Find(id);

            string   photoDest = photoToDel.PhotoPath.Substring(1);
            string   path      = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, photoDest);
            FileInfo file      = new FileInfo(path);

            if (file.Exists)
            {
                file.Delete();
            }

            context.Photos.Remove(photoToDel);
            context.SaveChanges();

            return(Json("OK"));
        }
Ejemplo n.º 17
0
        public void SetChangesForEmployee(int employeeId, int positionId, int projectId, string lastName, string middleName, string firstName, DateTime dateOfBirth, Gender gender, string nationality, string nID)
        {
            var employee = _dbContext.Employees.Find(employeeId);
            var position = _dbContext.Positions.Find(positionId);
            var project  = _dbContext.Projects.Find(projectId);

            employee.Position    = position;
            employee.Project     = project;
            employee.FirstName   = firstName;
            employee.MiddleName  = middleName;
            employee.LastName    = lastName;
            employee.DateOfBirth = dateOfBirth;
            employee.Gender      = gender;
            employee.Nationality = nationality;
            employee.NationalIdentificationNumber = nID;

            _dbContext.SaveChanges();
        }
 public void Add(PersonAddress newPersonAddress)
 {
     _context.Add(newPersonAddress);
     _context.SaveChanges();
 }
 public void Add(ContractOrganizatoricalAssignment coa)
 {
     _context.Add(coa);
     _context.SaveChanges();
 }
Ejemplo n.º 20
0
 public ActionResult Edit(JobTitle j)
 {
     context.JobTitles.AddOrUpdate(j);
     context.SaveChanges();
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 21
0
        //public IRepository<T> Repository<T>() where T : BaseEntity
        //{
        //    if (repositories.Keys.Contains(typeof(T)) == true)
        //    {
        //        return repositories[typeof(T)] as IRepository<T>;
        //    }
        //    IRepository<T> repo = new GenericRepository<T>(entities);
        //    repositories.Add(typeof(T), repo);
        //    return repo;
        //}

        public void Save()
        {
            entities.SaveChanges();
        }
 public void Add(PersonIdentity newPersonIdentity)
 {
     _context.Add(newPersonIdentity);
     _context.SaveChanges();
 }
 public void Add(ContractInsurance contractInsurance)
 {
     _context.Add(contractInsurance);
     _context.SaveChanges();
 }
Ejemplo n.º 24
0
 public bool SaveChanges()
 {
     return(context.SaveChanges() > 0);
 }
Ejemplo n.º 25
0
        public JsonResult GeneratePayroll(string ids)
        {
            if (string.IsNullOrEmpty(ids))
            {
                return(Json(new { status = "404" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                string[] arrID = ids.Split(',');
                if (arrID.Length > 0)
                {
                    bool   isValid = false;
                    string empID   = null;
                    for (int a = 0; a < arrID.Length; a++)
                    {
                        Guid attID = new Guid(arrID[a]);

                        //Approved Checked
                        bool isValidAtt = db.Attendance.Where(x => x.Id == attID).Select(x => x.Approved.HasValue).Single(); //return false jika Approved = NULL
                        if (!isValidAtt)
                        {
                            isValid = false;
                            break;
                        }
                        else
                        {
                            isValid = db.Attendance.Where(x => x.Id == attID).Select(x => x.Approved.Value).Single();
                            if (!isValid)
                            {
                                break;
                            }
                        }

                        //Same Employee Checked
                        string userID = db.Attendance.Where(x => x.Id == attID).Select(x => x.UserAccounts_Id).Single().ToString();
                        if (a == 0)
                        {
                            empID = userID;
                        }
                        else
                        {
                            isValid = (empID == userID) ? true : false;
                        }
                    }

                    if (!isValid)
                    {
                        return(Json(new { status = "405" }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        Guid _attID     = new Guid(arrID[0]);
                        Guid employeeID = db.Attendance.Where(x => x.Id == _attID).Select(x => x.UserAccounts_Id).Single();

                        PayrollModels pRoll = new PayrollModels();
                        pRoll.Id        = Guid.NewGuid();
                        pRoll.Timestamp = DateTime.Now;
                        pRoll.Employee_UserAccounts_Id = employeeID;
                        pRoll.Amount = 0;
                        Common.Master m = new Common.Master();
                        pRoll.No         = m.GetLastHexNo("payroll").ToString("00000");
                        pRoll.hasPayment = false;
                        db.Payroll.Add(pRoll);
                        db.SaveChanges();

                        for (int i = 0; i < arrID.Length; i++)
                        {
                            Guid attID           = new Guid(arrID[i]);
                            PayrollItemModels pi = new PayrollItemModels();
                            pi.Id          = Guid.NewGuid();
                            pi.Payrolls_Id = pRoll.Id;
                            pi.RefId       = attID;
                            pi.Description = string.Empty;
                            int     hours   = db.Attendance.Where(x => x.Id == attID).Select(x => x.Workshifts_DurationMinutes.Value).Single() / 60;
                            decimal payRate = db.Attendance.Where(x => x.Id == attID).Select(x => x.AttendancePayRates_Amount.Value).FirstOrDefault();
                            pi.Amount = hours * payRate;
                            pi.Notes  = string.Empty;
                            db.PayrollItem.Add(pi);
                            db.SaveChanges();

                            using (var ctx = new HrContext())
                            {
                                int result = ctx.Database.ExecuteSqlCommand("UPDATE Attendances SET PayrollItems_Id='" + pi.Id + "' WHERE Id='" + attID + "'");
                            }
                        }

                        decimal total_amount  = db.PayrollItem.Where(x => x.Payrolls_Id == pRoll.Id).Select(x => x.Amount).Sum();
                        int     update_amount = db.Database.ExecuteSqlCommand("UPDATE Payrolls SET Amount=" + total_amount + " WHERE Id='" + pRoll.Id + "'");

                        return(Json(new { status = "200" }, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json(new { status = "404" }, JsonRequestBehavior.AllowGet));
                }
            } //end ids is not null/empty
        }     //end generate payroll
Ejemplo n.º 26
0
 public void Add(Contract newContract)
 {
     _context.Add(newContract);
     _context.SaveChanges();
 }
Ejemplo n.º 27
0
 public void Add(ContractFiscality contractFiscality)
 {
     _context.Add(contractFiscality);
     _context.SaveChanges();
 }
Ejemplo n.º 28
0
 public void Add(Person newPerson)
 {
     _context.Add(newPerson);
     _context.SaveChanges();
 }
Ejemplo n.º 29
0
 public void Add(ContractPeriod contractPeriod)
 {
     _context.Add(contractPeriod);
     _context.SaveChanges();
 }
 public void Add(ContractWorkProgram contractWorkProgram)
 {
     _context.Add(contractWorkProgram);
     _context.SaveChanges();
 }