Esempio n. 1
0
        /// <summary>
        /// Remove auto
        /// </summary>
        /// <param name="number">Number of the auto to delete</param>
        public void RemoveAuto(string number)
        {
            AutoRentEntities context     = new AutoRentEntities();
            DbTransaction    transaction = null;

            try
            {
                context.Connection.Open();
                transaction = context.Connection.BeginTransaction();

                context.Auto.DeleteObject(context.Auto.First(o => o.Number == number));

                context.SaveChanges();
                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
            }
            finally
            {
                context.Connection.Close();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create new department
        /// </summary>
        /// <param name="department">Department to add</param>
        public Guid CreateDepartment(Department department)
        {
            AutoRentEntities context     = new AutoRentEntities();
            DbTransaction    transaction = null;

            try
            {
                department.Id = Guid.NewGuid();
                context.Connection.Open();
                transaction = context.Connection.BeginTransaction();
                context.AddToDepartment(department);
                context.SaveChanges();
                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
            }
            finally
            {
                context.Connection.Close();
            }
            return(department.Id);
        }
Esempio n. 3
0
        public void RemoveEmployeProfile(Guid guid)
        {
            AutoRentEntities context     = new AutoRentEntities();
            DbTransaction    transaction = null;

            try
            {
                context.Connection.Open();
                transaction = context.Connection.BeginTransaction();

                context.Employee.DeleteObject(context.Employee.First(o => o.Id == guid));

                context.SaveChanges();
                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
            }
            finally
            {
                context.Connection.Close();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Remove damages
        /// </summary>
        /// <param name="id">Id of the damages to delete</param>
        public void RemoveDamages(int id)
        {
            AutoRentEntities context     = new AutoRentEntities();
            DbTransaction    transaction = null;

            try
            {
                context.Connection.Open();
                transaction = context.Connection.BeginTransaction();

                context.Damages.DeleteObject(context.Damages.First(o => o.Id == id));

                context.SaveChanges();
                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
            }
            finally
            {
                context.Connection.Close();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Create new customer profile
        /// </summary>
        /// <param name="employee">Added customer</param>
        public Guid CreateCustomerProfile(Customer customer)
        {
            AutoRentEntities context     = new AutoRentEntities();
            DbTransaction    transaction = null;

            try
            {
                customer.Id = Guid.NewGuid();
                context.Connection.Open();
                transaction = context.Connection.BeginTransaction();
                context.AddToCustomer(customer);
                context.SaveChanges();
                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
            }
            finally
            {
                context.Connection.Close();
            }
            return(customer.Id);
        }
Esempio n. 6
0
        /// <summary>
        /// Create new employee profile
        /// </summary>
        /// <param name="employee">Added employee</param>
        public Guid CreateEmployeProfile(Employee employee)
        {
            AutoRentEntities context     = new AutoRentEntities();
            DbTransaction    transaction = null;

            try
            {
                employee.Id = Guid.NewGuid();
                context.Connection.Open();
                transaction = context.Connection.BeginTransaction();
                context.AddToEmployee(employee);
                context.SaveChanges();
                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
            }
            finally
            {
                context.Connection.Close();
            }
            return(employee.Id);
        }
Esempio n. 7
0
        public List <Members> UsersInRole(string roleName)
        {
            AutoRentEntities context = new AutoRentEntities();

            return(context.Roles.First(o => o.Name == roleName).Members.ToList());
        }
Esempio n. 8
0
        public List <PermissionRule> ListObjPermRulles()
        {
            AutoRentEntities context = new AutoRentEntities();

            return(context.PermissionRule.Select(o => o).ToList());
        }
Esempio n. 9
0
        public bool Authorize(string login, string passwd)
        {
            AutoRentEntities context = new AutoRentEntities();

            return(context.Members.Any(o => o.Lock == false && o.Login == login && o.Password == passwd));
        }