public AddNewTaskListViewModel SaveTempTaskRecord(AddNewTaskListViewModel Model, int UserId)
        {
            Employee_Task_Temp save = new Employee_Task_Temp();

            save.Title           = Model.Title;
            save.AlterBeforeDays = Model.AlertBeforeDays;
            save.Archived        = false;
            save.AssignTo        = Model.Assign;
            save.Created         = DateTime.Now;
            save.CreatedBy       = UserId;
            save.LastModified    = DateTime.Now;
            save.LastModifiedBy  = UserId;
            save.Status          = Model.Status;
            save.Description     = Model.Description;
            if (Model.DueDate != null)
            {
                var DyeDateToString = DateTime.ParseExact(Model.DueDate, inputFormat, CultureInfo.InvariantCulture);
                save.DueDate = Convert.ToDateTime(DyeDateToString.ToString(outputFormat));
            }
            _db.Employee_Task_Temp.Add(save);
            _db.SaveChanges();

            Model.Id     = save.Id;
            Model.IsTemp = 1;
            return(Model);
        }
        public void UpdateTaskRecord(AddNewTaskListViewModel model, int UserId)
        {
            if (model.IsTemp == 0)
            {
                Task_List record = _db.Task_List.Where(x => x.Id == model.IdRecord).FirstOrDefault();

                record.Title          = model.Title;
                record.Description    = model.Description;
                record.AssignTo       = model.Assign;
                record.LastModifiedBy = UserId;

                if (model.DueDate != null)
                {
                    var DyeDateToString = DateTime.ParseExact(model.DueDate, inputFormat, CultureInfo.InvariantCulture);
                    record.DueDate = Convert.ToDateTime(DyeDateToString.ToString(outputFormat));
                }
                record.AlterBeforeDays = model.AlertBeforeDays;
                record.Status          = model.Status;
                record.Difualt         = true;
                record.LastModified    = DateTime.Now;
                _db.SaveChanges();
            }
            else
            {
                Employee_Task_Temp save = _db.Employee_Task_Temp.Where(x => x.Id == model.IdRecord).FirstOrDefault();
                save.Title       = model.Title;
                save.Description = model.Description;
                save.AssignTo    = model.Assign;
                if (model.DueDate != null)
                {
                    var DyeDateToString = DateTime.ParseExact(model.DueDate, inputFormat, CultureInfo.InvariantCulture);
                    save.DueDate = Convert.ToDateTime(DyeDateToString.ToString(outputFormat));
                }
                save.AlterBeforeDays = model.AlertBeforeDays;
                save.Status          = model.Status;
                save.LastModified    = DateTime.Now;
                _db.SaveChanges();
            }
        }
Exemplo n.º 3
0
        public AddNewTaskListViewModel SaveTempTaskRecord(AddNewTaskListViewModel Model, int UserId)
        {
            Employee_Task_Temp save = new Employee_Task_Temp();

            save.Title           = Model.Title;
            save.AlterBeforeDays = Model.AlertBeforeDays;
            save.Archived        = false;
            save.AssignTo        = Model.Assign;
            save.Created         = DateTime.Now;
            save.CreatedBy       = UserId;
            save.LastModified    = DateTime.Now;
            save.LastModifiedBy  = UserId;
            save.Status          = Model.Status;
            save.Description     = Model.Description;
            if (Model.DueDate != null)
            {
                var DyeDateToString = Model.DueDate;
            }
            _db.Employee_Task_Temp.Add(save);
            _db.SaveChanges();
            Model.Id     = save.Id;
            Model.IsTemp = 1;
            return(Model);
        }