Beispiel #1
0
 public bool UnDeleteOrganization(long admin_id, long organization_id)
 {
     using (VIMSDBContext context = new VIMSDBContext())
     {
         Organization organization = context.Organizations.Find(organization_id);
         if (organization != null && organization.Active != true)
         {
             organization.Active    = true; // just set to active
             organization.UpdatedBy = admin_id;
             organization.UpdatedDt = System.DateTime.Now;
             context.SaveChanges();
             return(true);
         }
     }
     return(false);
 }
Beispiel #2
0
 public bool UnDeleteEmployee(long admin_id, long employee_id)
 {
     using (VIMSDBContext context = new VIMSDBContext())
     {
         Employee employee = context.Employees.Find(employee_id);
         if (employee != null && employee.Active != true)
         {
             employee.Active    = true; // just set to active
             employee.UpdatedBy = admin_id;
             employee.UpdatedDt = System.DateTime.Now;
             context.SaveChanges();
             return(true);
         }
     }
     return(false);
 }
Beispiel #3
0
        public bool UnEditOrganization(Organization organization)
        {
            using (VIMSDBContext context = new VIMSDBContext())
            {
                Organization current_organization = context.Organizations.Find(organization.Id);
                if (organization != null && (bool)organization.Active) // BKP fix should not be nullable
                {
                    int count = context.Organizations.
                                Where(m => m.Name == organization.Name && m.Id != organization.Id).
                                Count();

                    if (count == 0)
                    {
                        context.Entry(current_organization).CurrentValues.SetValues(organization);
                        context.SaveChanges();
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #4
0
        public bool EditEmployee(Employee employee)
        {
            using (VIMSDBContext context = new VIMSDBContext())
            {
                Employee current_employee = context.Employees.Find(employee.Id);
                if (employee != null && (bool)employee.Active) // BKP fix should not be nullable
                {
                    int count = context.Employees.
                                Where(m => m.UserName == employee.UserName && m.Id != employee.Id).
                                Count();

                    if (count == 0)
                    {
                        employee.UpdatedDt = System.DateTime.Now;
                        context.Entry(current_employee).CurrentValues.SetValues(employee);
                        context.SaveChanges();
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #5
0
 public int Save()
 {
     return(context.SaveChanges());
 }
Beispiel #6
0
 public void Save()
 {
     context.SaveChanges();
 }