Ejemplo n.º 1
0
        public ActionResult ShiftControlInsert(ShiftControlModel shiftControlModel)
        {
            if (shiftControlModel.Entry.Year == DateTime.Today.Year)
            {
                hourRegister.InsertInitialHour(shiftControlModel, shiftControlModel.Entry);
            }
            if (shiftControlModel.Exit.Year == DateTime.Today.Year)
            {
                hourRegister.InsertExitHour(shiftControlModel, shiftControlModel.Exit);
            }

            //            return View("EmployeeTurn",hourRegister.ControltEmployeesHours(shiftControlModel.ID));
            return(RedirectToAction("Register2"));
        }
Ejemplo n.º 2
0
        public List <ShiftControlModel> ControltEmployeesHours(int id)
        {
            var electedShift = repoShift.Read(id);

            var listEmployee = repoEmployees.ReadAll().Where(c => c.CurrentShift.ID == electedShift.ID);

            var listModel = new List <ShiftControlModel>();

            if (listEmployee != null)
            {
                foreach (var y in listEmployee)
                {
                    var auxEmployee = new EmployeeModel();

                    var modify = new ShiftControlModel();

                    if (y != null)
                    {
                        modify.Employee = new ConvertEmployee().ConvertModel(y);
                    }


                    var aux = repoControl.Read(DateTime.Today, y.ID);

                    if (aux != null)
                    {
                        modify.ID = aux.ID;

                        modify.Day = DateTime.Today;
                        if (aux.Entry != null)
                        {
                            modify.Entry = (DateTime)aux.Entry;
                        }

                        if (aux.Exit != null)
                        {
                            modify.Exit = (DateTime)aux.Exit;
                        }

                        modify.WorkedHours = aux.WorkedHours;

                        listModel.Add(modify);
                    }
                }
            }

            return(listModel);
        }
Ejemplo n.º 3
0
        public int InsertInitialHour(ShiftControlModel shift, DateTime hour)
        {
            try
            {
                var shiftControl = new ShiftControl
                {
                    ID    = shift.ID,
                    Entry = hour,
                    Exit  = shift.Exit
                };

                repoControl.Update(shiftControl);

                return(1);
            }
            catch
            {
                return(0);
            }
        }
Ejemplo n.º 4
0
        public int InsertExitHour(ShiftControlModel shift, DateTime hour)
        {
            try
            {
                var shiftControl = new ShiftControl
                {
                    ID          = shift.ID,
                    Entry       = shift.Entry,
                    Exit        = hour,
                    WorkedHours = CalculateWork(shift.Entry, hour)
                };

                repoControl.Update(shiftControl);

                return(1);
            }
            catch
            {
                return(0);
            }
        }
Ejemplo n.º 5
0
        public List <ShiftControlModel> FirstEmployeesHours(int shift)
        {
            var electedShift = repoShift.Read(shift);

            var listEmployee = repoEmployees.ReadAll().Where(c => c.CurrentShift.ID == shift);

            var listModel = new List <ShiftControlModel>();

            var shiftcontrol = new ShiftControlModel();

            if (listEmployee != null)
            {
                foreach (var x in listEmployee)
                {
                    var shifttData = new ShiftControl
                    {
                        Employee = x,
                        Day      = DateTime.Today
                    };

                    repoControl.Create(shifttData);

                    var auxEmployee = new EmployeeModel();

                    if (x != null)
                    {
                        auxEmployee = new ConvertEmployee().ConvertModel(x);
                    }

                    listModel.Add(new ShiftControlModel()
                    {
                        ID       = repoControl.Read(DateTime.Today, x.ID).ID,
                        Employee = auxEmployee,
                        Day      = DateTime.Today,
                    });
                }
            }

            return(listModel);
        }
Ejemplo n.º 6
0
 public ActionResult ShiftControl(ShiftControlModel shiftControlModel, int section)
 {
     ViewBag.Section = section;
     return(View("ShiftControl", shiftControlModel));
 }
Ejemplo n.º 7
0
 public bool ExitHourVerification(ShiftControlModel shift) => shift.Exit == null;
Ejemplo n.º 8
0
 public bool EntryHourVerification(ShiftControlModel shift) => shift.Entry == null;