Example #1
0
        // GET: Tasks/CreateNumber_hours
        public ActionResult CreateTask(TaskObject taskObj)
        {
            Task task = new Task();

            task.Date                 = taskObj.Date;
            task.Number_hours         = taskObj.Number_hours;
            task.Hour_type            = taskObj.Hour_type;
            task.Activity_Id          = taskObj.Activity;
            task.Id_labor             = taskObj.Labor;
            task.Ext_Attr_Labor_Value = taskObj.Ext_Attr;
            task.Id_location          = taskObj.Location;
            task.Name                 = task.Task_Id.ToString();
            try
            {
                task.UserId = db.User.Where(x => x.Username == User.Identity.Name).Select(x => x.UserId).FirstOrDefault();
                db.Tasks.Add(task);
                db.SaveChanges();
                return(RedirectToAction("Index", new { added = true }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Algo salio mal, intente nuevamente");
                return(RedirectToAction("Index", new { addFailed = true }));
            }
        }
Example #2
0
        public ActionResult Add_Activity(TaskObject taskObj)
        {
            Task task = new Task();

            task.Number_hours   = taskObj.Number_hours;
            task.Hour_type      = taskObj.Hour_type;
            ViewBag.Activity_Id = new SelectList(db.Activities, "Activity_Id", "Activity_name");
            return(View(task));
        }
Example #3
0
        public ActionResult Add_Labor(TaskObject taskObj)
        {
            Task task = new Task();

            task.Number_hours = taskObj.Number_hours;
            task.Hour_type    = taskObj.Hour_type;
            task.Activity_Id  = taskObj.Activity;
            ViewBag.Id_labor  = new SelectList(db.Labors, "Id_labor", "Name");
            return(View(task));
        }
Example #4
0
        public ActionResult Add_Location(TaskObject taskObj)
        {
            Task task = new Task();

            task.Number_hours         = taskObj.Number_hours;
            task.Hour_type            = taskObj.Hour_type;
            task.Activity_Id          = taskObj.Activity;
            task.Id_labor             = taskObj.Labor;
            task.Ext_Attr_Labor_Value = taskObj.Ext_Attr;
            ViewBag.Id_location       = new SelectList(db.Locations, "Id_location", "Name");
            return(View(task));
        }
Example #5
0
        public ActionResult Add_Hour_type(TaskObject taskObj)
        {
            Task task = new Task();

            task.Number_hours = taskObj.Number_hours;
            List <string> hourTypeOption = new List <string>();

            hourTypeOption.Add("Ordinaria");
            hourTypeOption.Add("Extraordinaria");
            ViewBag.Hour_type = new SelectList(hourTypeOption);
            return(View(task));
        }
Example #6
0
        public ActionResult Create(TaskObject taskObj)
        {
            Task task = new Task();

            task.Number_hours         = taskObj.Number_hours;
            task.Hour_type            = taskObj.Hour_type;
            task.Activity_Id          = taskObj.Activity;
            task.Id_labor             = taskObj.Labor;
            task.Ext_Attr_Labor_Value = taskObj.Ext_Attr;
            task.Id_location          = taskObj.Location;
            return(View(task));
        }
Example #7
0
 public ActionResult Add_Num_Hours(Task model)
 {
     if (model.Number_hours == null)
     {
         ModelState.AddModelError("", "Debe ingresar el numero de horas!!!");
     }
     if (ModelState.IsValid)
     {
         TaskObject taskObject = new TaskObject();
         taskObject.Number_hours = model.Number_hours;
         return(RedirectToAction("Add_Hour_type", taskObject));
     }
     return(View(model));
 }
Example #8
0
 public ActionResult Add_Hour_type(Task model)
 {
     if (model.Hour_type == null)
     {
         ModelState.AddModelError("", "Debe ingresar el tipo de hora!!!");
     }
     if (ModelState.IsValid)
     {
         TaskObject taskObject = new TaskObject();
         taskObject.Number_hours = model.Number_hours;
         taskObject.Hour_type    = model.Hour_type;
         return(RedirectToAction("Add_Activity", taskObject));
     }
     return(View(model));
 }
Example #9
0
 public ActionResult Add_Activity(Task model)
 {
     if (model.Activity_Id == 0)
     {
         ModelState.AddModelError("", "Debe seleccionar una actividad!!!");
     }
     if (ModelState.IsValid)
     {
         TaskObject taskObject = new TaskObject();
         taskObject.Number_hours = model.Number_hours;
         taskObject.Hour_type    = model.Hour_type;
         taskObject.Activity     = model.Activity_Id;
         return(RedirectToAction("Add_Labor", taskObject));
     }
     return(View(model));
 }
Example #10
0
 public ActionResult Add_Location(Task model)
 {
     if (model.Id_location == 0)
     {
         ModelState.AddModelError("", "Debe seleccionar una ubicacion");
     }
     if (ModelState.IsValid)
     {
         TaskObject taskObject = new TaskObject();
         taskObject.Number_hours = model.Number_hours;
         taskObject.Hour_type    = model.Hour_type;
         taskObject.Activity     = model.Activity_Id;
         taskObject.Labor        = model.Id_labor;
         taskObject.Ext_Attr     = model.Ext_Attr_Labor_Value;
         taskObject.Location     = model.Id_location;
         return(RedirectToAction("Create", taskObject));
     }
     return(View(model));
 }
Example #11
0
        public ActionResult Add_Ext_Attr(TaskObject taskObj)
        {
            Task task = new Task();

            task.Number_hours = taskObj.Number_hours;
            task.Hour_type    = taskObj.Hour_type;
            task.Activity_Id  = taskObj.Activity;
            task.Id_labor     = taskObj.Labor;
            var ex = db.Labors.Include(e => e.ExtendedAttribute)
                     .Where(x => x.Id_labor == task.Id_labor)
                     .Select(x => x.ExtendedAttribute.Name)
                     .FirstOrDefault();

            ViewBag.Ext_Attr = ex;
            if (ex == null)
            {
                return(RedirectToAction("Add_Location", taskObj));
            }
            return(View(task));
        }
Example #12
0
 public ActionResult Create(Task model)
 {
     if (model.Date == null)
     {
         ModelState.AddModelError("", "Debe ingresar un valor para la fecha!!!");
     }
     if (ModelState.IsValid)
     {
         TaskObject taskObject = new TaskObject();
         taskObject.Date         = model.Date;
         taskObject.Number_hours = model.Number_hours;
         taskObject.Hour_type    = model.Hour_type;
         taskObject.Activity     = model.Activity_Id;
         taskObject.Labor        = model.Id_labor;
         taskObject.Ext_Attr     = model.Ext_Attr_Labor_Value;
         taskObject.Location     = model.Id_location;
         return(RedirectToAction("CreateTask", taskObject));
     }
     return(View(model));
 }
Example #13
0
        public ActionResult Add_Num_Hours(TaskObject taskObj)
        {
            Task task = new Task();

            return(View(task));
        }