Example #1
0
        public bool UpdateOrganization(Organization organization)
        {
            Organization organization_current = FindOrganization(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)
                {
                    //organization.UpdatedBy = admin_id; // todo
                    organization.UpdatedDt = System.DateTime.Now;
                    context.Entry(organization_current).CurrentValues.SetValues(organization);
                    context.SaveChanges();
                    return(true);
                }
            }
            return(false);
        }
Example #2
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);
        }
Example #3
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);
        }