예제 #1
0
        public bool update(string user, User inforChange)
        {
            var userRemove = findUser(user);

            if (userRemove != null)
            {
                context.Entry(inforChange).State = EntityState.Modified;
                context.SaveChanges();
                return(true);
            }
            return(false);
        }
        public void SwitchOrganization(String userId, int targetOrganizationId, int oldOrganizationId)
        {
            var getOrganization = context.Organization.Where(o => o.Id == targetOrganizationId).FirstOrDefault();
            var oldOrganization = context.Organization.Where(o => o.Id == oldOrganizationId).FirstOrDefault();

            if (oldOrganization != null)
            {
                oldOrganization.CurrentOrganization  = false;
                context.Entry(oldOrganization).State = EntityState.Modified;
            }
            getOrganization.CurrentOrganization = true;

            context.Entry(getOrganization).State = EntityState.Modified;
            context.SaveChanges();
        }
예제 #3
0
        public async Task <IActionResult> PutWorkflowDetail(int id, WorkflowDetail WorkflowDetail)
        {
            if (id != WorkflowDetail.WFId)
            {
                return(BadRequest());
            }
            _context.Entry(WorkflowDetail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WorkflowDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #4
0
 public IActionResult DataChange(User user, string newPassword, string confirmPassword)
 {
     if (newPassword == null || confirmPassword == null)
     {
         _context.Entry(user).State = EntityState.Modified;
         _context.SaveChanges();
         return(RedirectToAction("Index", "Home"));
     }
     else if (newPassword == confirmPassword && newPassword != null && confirmPassword != null)
     {
         user.UPassword             = MD5Hash(newPassword);
         _context.Entry(user).State = EntityState.Modified;
         _context.SaveChanges();
     }
     return(RedirectToAction("DataChange", "Home"));
 }
        public virtual TEntity Update(TEntity obj)
        {
            var entry = Db.Entry(obj);

            DbSet.Attach(obj);
            entry.State = EntityState.Modified;
            Db.SaveChanges();
            return(obj);
        }
예제 #6
0
 public T Update(T entity)
 {
     using (var dbContext = new WorkflowContext())
     {
         var repository = dbContext.Set <T>();
         repository.Attach(entity);
         dbContext.Entry(entity).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
     return(entity);
 }
예제 #7
0
 public void UpdateFingerPrintStatus(string status)
 {
     using (var dbContext = new WorkflowContext()) {
         var fingerPrintMachine = dbContext.FingerPrintMachines.FirstOrDefault(p => p.IP == IP);
         if (fingerPrintMachine != null)
         {
             fingerPrintMachine.LastConnectedDate = DateTime.Now;
             fingerPrintMachine.Status            = status;
             dbContext.FingerPrintMachines.Attach(fingerPrintMachine);
             dbContext.Entry(fingerPrintMachine).State = EntityState.Modified;
             if (dbContext.ChangeTracker.HasChanges())
             {
                 dbContext.SaveChanges();
             }
         }
     }
 }
예제 #8
0
 private void IClockClient_OnConnected()
 {
     logger.Info("IClockClient_OnConnected");
     IsConnected = true;
     using (var dbContext = new WorkflowContext()) {
         var fingerPrintMachine = dbContext.FingerPrintMachines.FirstOrDefault(p => p.IP == IP);
         if (fingerPrintMachine != null)
         {
             fingerPrintMachine.ConnectedDate = DateTime.Now;
             fingerPrintMachine.Status        = STATUS_CONNECTED;
             dbContext.FingerPrintMachines.Attach(fingerPrintMachine);
             dbContext.Entry(fingerPrintMachine).State = EntityState.Modified;
             if (dbContext.ChangeTracker.HasChanges())
             {
                 dbContext.SaveChanges();
             }
         }
     }
 }
예제 #9
0
        // update template
        public void updateTaskItems(List <TaskItemViewModel> taskItem)
        {
            int?checklistId = 0;

            foreach (var item in taskItem)
            {
                if (item.TaskStatus.Equals("Template"))
                {
                    var currentTask = new TaskItem();
                    currentTask.Id                   = item.Id;
                    currentTask.ChecklistId          = item.ChecklistId;
                    checklistId                      = item.ChecklistId;
                    currentTask.DueTime              = DateTime.Parse(item.DueTime);
                    currentTask.Name                 = item.Name;
                    currentTask.Priority             = item.Priority;
                    currentTask.TaskStatus           = item.TaskStatus;
                    context.Entry(currentTask).State = EntityState.Modified;
                    context.SaveChanges();
                    //var getTask = context.TaskItem.Where(t => t.Name.Equals(item.Name) && t.DueTime.Equals(task.DueTime)).FirstOrDefault();
                    foreach (var content in item.ContentDetails)
                    {
                        if (content.Id != 0)
                        {
                            context.Entry(content).State = EntityState.Modified;
                        }
                    }
                    context.SaveChanges();
                }
                else
                {
                    List <ContentDetail> contentDetails = new List <ContentDetail>();
                    List <TaskMember>    taskMembers    = new List <TaskMember>();
                    TaskItem             task           = new TaskItem();
                    task.ChecklistId = checklistId;
                    task.DueTime     = DateTime.ParseExact(item.DueTime, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                    task.Name        = item.Name;
                    task.Priority    = item.Priority;
                    //task.TaskStatus = item.TaskStatus;
                    task.TaskStatus = "Template";
                    context.TaskItem.Add(task);
                    context.SaveChanges();
                    var getTask = context.TaskItem.Where(t => t.Name.Equals(item.Name) && t.DueTime.Equals(task.DueTime) && t.TaskStatus.Equals("Template")).FirstOrDefault();
                    var i       = 1;
                    foreach (var content in item.ContentDetails)
                    {
                        if (content.Id != 0)
                        {
                            ContentDetail detail = new ContentDetail();
                            detail.ImageSrc     = content.ImageSrc;
                            detail.Label        = content.Label;
                            detail.OrderContent = i;
                            detail.TaskItemId   = getTask.Id;
                            detail.Text         = content.Text;
                            detail.Type         = content.Type;
                            contentDetails.Add(detail);
                        }
                        i++;
                    }
                    foreach (var user in item.UserId)
                    {
                        TaskMember member = new TaskMember();
                        member.UserId = user.Id;
                        member.TaskId = getTask.Id;
                        taskMembers.Add(member);
                    }
                    context.ContentDetail.AddRange(contentDetails);
                    context.TaskMember.AddRange(taskMembers);
                    context.SaveChanges();

                    //context.Task
                }
            }
        }
 public IActionResult EditUser(User user)
 {
     _context.Entry(user).State = EntityState.Modified;
     _context.SaveChanges();
     return(RedirectToAction("UserTable", "Administration"));
 }