Exemple #1
0
        public BusinessObjects.Status EditStatus(int Id)
        {
            Logger.TraceMethodStart(ClassName, "EditStatus");

            var status = default(BusinessObjects.Status);

            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var query = db.Status.Where(c => c.ID == Id && c.Active).FirstOrDefault();
                    status = MapperAllLevels.Map <EntityModel.Status, BusinessObjects.Status>(query);
                    return(status);
                }
            }

            catch (Exception ex)
            {
                Logger.TraceError("Exception: ", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName, "EditStatus");
            }
        }
        public List <BusinessObjects.Organization> DropDownOrganisation()
        {
            Logger.TraceMethodStart(ClassName, "DropDownOrganisation");


            var dropdown = default(List <BusinessObjects.Organization>);

            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var Organisationquery = db.Organizations.Where(c => c.Active).ToList();
                    dropdown = MapperAllLevels.Map <List <EntityModel.Organization>, List <BusinessObjects.Organization> >(Organisationquery);
                    return(dropdown);
                }
            }

            catch (Exception ex)
            {
                Logger.TraceError("Exception: ", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName, "DropDownOrganisation");
            }
        }
        public List <BusinessObjects.Product> DropDownProduct()
        {
            Logger.TraceMethodStart(ClassName);


            var dropdown = default(List <BusinessObjects.Product>);

            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var Productquery = db.Products.Where(c => c.Active == true).ToList();
                    dropdown = MapperAllLevels.Map <List <EntityModel.Product>, List <BusinessObjects.Product> >(Productquery);
                    return(dropdown);
                }
            }

            catch (Exception ex)
            {
                Logger.TraceError("Exception: ", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName, "DropDownProduct");
            }
        }
Exemple #4
0
        public List <BusinessObjects.Category> DropDownCategory()
        {
            Logger.TraceMethodStart(ClassName);


            var dropdown = default(List <BusinessObjects.Category>);


            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var Categoryquery = db.Categories.Select(c => c).Where(d => d.Active).ToList();
                    dropdown = MapperAllLevels.Map <List <EntityModel.Category>, List <BusinessObjects.Category> >(Categoryquery);
                    return(dropdown);
                }
            }

            catch (Exception ex)
            {
                Logger.TraceError("Exception: ", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName, "DropDownCategory");
            }
        }
        public List <BusinessObjects.ProductOrganisation> GetProductOrganizationList()
        {
            Logger.TraceMethodStart(ClassName, "GetProductOrganizationList");

            var prod = default(List <BusinessObjects.ProductOrganisation>);


            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var query = db.ProductOrganisations.Where(c => c.Active == true)
                                .Include(x => x.Product)
                                .Include(x => x.Organization).ToList();
                    ;

                    prod = MapperAllLevels.Map <List <EntityModel.ProductOrganisation>, List <BusinessObjects.ProductOrganisation> >(query);
                    return(prod);
                }
            }
            catch (Exception ex)
            {
                Logger.TraceError("Exception:", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName, "GetProductOrganizationList");
            }
        }
        public BusinessObjects.User DeleteUser(int Id)
        {
            Logger.TraceMethodStart(ClassName, "DeleteUser");
            var user = default(BusinessObjects.User);

            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var query = db.Users.Where(c => c.ID == Id && c.Active == true).FirstOrDefault();
                    user = MapperAllLevels.Map <EntityModel.User, BusinessObjects.User>(query);
                    return(user);
                }
            }

            catch (Exception ex)
            {
                Logger.TraceError("Exception: ", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName, "DeleteUser");
            }
        }
Exemple #7
0
        public BusinessObjects.AspNetRole EditRole(string Id)
        {
            Logger.TraceMethodStart(ClassName, "EditRole");

            var role = default(BusinessObjects.AspNetRole);

            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var query = db.AspNetRoles.Where(c => c.Id == Id && c.Active == true).FirstOrDefault();
                    role = MapperAllLevels.Map <DAL.EntityModel.AspNetRole, BusinessObjects.AspNetRole>(query);
                    return(role);
                }
            }

            catch (Exception ex)
            {
                Logger.TraceError("Exception ex", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName, "EditRole");
            }
        }
Exemple #8
0
        public List <BusinessObjects.Status> GetStatus()
        {
            Logger.TraceMethodStart(ClassName, "GetStatus");

            var status = default(List <BusinessObjects.Status>);


            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var query = db.Status.Where(c => c.Active).ToList();
                    status = MapperAllLevels.Map <List <EntityModel.Status>, List <BusinessObjects.Status> >(query);
                    return(status);
                }
            }

            catch (Exception ex)
            {
                Logger.TraceError("Exception: ", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName, "GetStatus");
            }
        }
        public BusinessObjects.Priority EditPriority(int Id)
        {
            Logger.TraceMethodStart(ClassName, "EditPriority");

            var prior = default(BusinessObjects.Priority);

            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var query = db.Priorities.Where(c => c.ID == Id && c.Active).FirstOrDefault();
                    prior = MapperAllLevels.Map <EntityModel.Priority, BusinessObjects.Priority>(query);
                    return(prior);
                }
            }

            catch (Exception ex)
            {
                Logger.TraceError("Exception: ", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName, "EditPriority");
            }
        }
        public BusinessObjects.ProductOrganisation DeleteOrganization(int Id)
        {
            Logger.TraceMethodStart(ClassName, "DeleteOrganization");
            var org = default(BusinessObjects.ProductOrganisation);


            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var query = db.ProductOrganisations.Where(c => c.ID == Id && c.Active == true).FirstOrDefault();
                    org = MapperAllLevels.Map <EntityModel.ProductOrganisation, BusinessObjects.ProductOrganisation>(query);
                    return(org);
                }
            }

            catch (Exception ex)
            {
                Logger.TraceError("Exception: ", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName, "DeleteOrganization");
            }
        }
        public BusinessObjects.Responsible DeleteResponsible(int Id)
        {
            Logger.TraceMethodStart(ClassName, "DeleteResponsible");
            var resp = default(BusinessObjects.Responsible);

            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    using (var transaction = db.Database.BeginTransaction())
                    {
                        var query = db.Responsibles.Where(c => c.ID == Id && c.Active == true).FirstOrDefault();
                        resp = MapperAllLevels.Map <EntityModel.Responsible, BusinessObjects.Responsible>(query);
                        return(resp);
                    }
                }
            }

            catch (Exception ex)
            {
                Logger.TraceError("Exception:", ex);
                throw;
            }


            finally
            {
                Logger.TraceMethodEnd(ClassName, "DeleteResponsible");
            }
        }
        public List <BusinessObjects.AspNetUser> SelectAll()
        {
            Logger.TraceMethodStart(ClassName);

            var boList = default(List <BusinessObjects.AspNetUser>);

            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var query = db.AspNetUsers.Where(x => x.Active == true).ToList();
                    boList = MapperAllLevels.Map <List <EntityModel.AspNetUser>, List <BusinessObjects.AspNetUser> >(query);
                    return(boList);
                }
            }
            catch (Exception ex)
            {
                Logger.TraceError("Exception: ", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName);
            }
        }
        public List <BusinessObjects.Product> GetProduct()
        {
            Logger.TraceMethodStart(ClassName, "GetProduct");

            var prod = default(List <BusinessObjects.Product>);

            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var query = db.Products.Where(c => c.Active == true).ToList();
                    //Logger.ServiceDebug($"FILTER: [{JsonExtensions.ToJson(query)}].", ClassName);

                    prod = MapperAllLevels.Map <List <EntityModel.Product>, List <BusinessObjects.Product> >(query);
                    return(prod);
                }
            }

            catch (Exception ex)
            {
                Logger.TraceError("Exception:", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName, "GetProduct");
            }
        }
        public void SaveUserRole(BusinessObjects.AspNetUserRole UserRole)
        {
            Logger.TraceMethodStart(ClassName, "Save");



            using (var db = new EntityModel.BugTrackingEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        UserRole.LastModified = DateTime.Now;
                        UserRole.Active       = true;
                        var newUserRole = MapperAllLevels.Map <BusinessObjects.AspNetUserRole, EntityModel.AspNetUserRole>(UserRole);
                        db.AspNetUserRoles.Add(newUserRole);
                        db.SaveChanges();
                        transaction.Commit();
                    }

                    catch (Exception ex)
                    {
                        Logger.TraceError("Exception: ", ex);
                        transaction.Rollback();
                    }

                    finally
                    {
                        Logger.TraceMethodEnd(ClassName, "Save");
                    }
                }
            }
        }
        public void SaveEditUser(BusinessObjects.User User)
        {
            Logger.TraceMethodStart(ClassName, "SaveEditUser");



            using (var db = new EntityModel.BugTrackingEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        User.LastModified = DateTime.Now;
                        var resp = MapperAllLevels.Map <BusinessObjects.User, EntityModel.User>(User);
                        db.Entry(resp).State = EntityState.Modified;
                        db.SaveChanges();
                        transaction.Commit();
                    }

                    catch (Exception ex)
                    {
                        Logger.TraceError("Exception: ", ex);
                        transaction.Rollback();
                    }

                    finally
                    {
                        Logger.TraceMethodEnd(ClassName, "SaveEditUser");
                    }
                }
            }
        }
        public List <BusinessObjects.User> GetInactiveUserList()
        {
            Logger.TraceMethodStart(ClassName, "GetInactiveUserList");
            var users = default(List <BusinessObjects.User>);

            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var query = db.Users.Where(c => c.Active == false)
                                .ToList();

                    users = MapperAllLevels.Map <List <EntityModel.User>, List <BusinessObjects.User> >(query);
                    return(users);
                }
            }
            catch (Exception ex)
            {
                Logger.TraceError("Exception:", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName, "GetInactiveUserList");
            }
        }
        public BusinessObjects.Product EditProduct(long Id)
        {
            Logger.TraceMethodStart(ClassName, "EditProduct");

            var prod = default(BusinessObjects.Product);

            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var query = db.Products.Where(c => c.ID == Id && c.Active == true).FirstOrDefault();
                    prod = MapperAllLevels.Map <EntityModel.Product, BusinessObjects.Product>(query);
                    return(prod);
                }
            }

            catch (Exception ex)
            {
                Logger.TraceError("Exception ex", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName, "EditProduct");
            }
        }
        public BugTrackingResponse <BusinessObjects.ProductOrganisation> DeleteOrganizationConfirmed(int Id)
        {
            Logger.TraceMethodStart(ClassName, "DeleteOrganizationConfirmed");

            var response = new BugTrackingResponse <BusinessObjects.ProductOrganisation>();


            using (var db = new EntityModel.BugTrackingEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var query   = db.ProductOrganisations.Where(c => c.ID == Id && c.Active == true).FirstOrDefault();
                        var prodorg = MapperAllLevels.Map <EntityModel.ProductOrganisation, BusinessObjects.ProductOrganisation>(query);

                        var validator = new ProdOrganizationDeleteSpecification();
                        var result    = validator.Validate(prodorg);
                        var failures  = result.Errors;

                        response.ValidationResult = result;

                        if (result.IsValid)
                        {
                            //db.ProductOrganisations.Remove(query);
                            query.Active       = false;
                            query.LastModified = DateTime.Now;
                            db.SaveChanges();
                            transaction.Commit();
                        }

                        else
                        {
                            transaction.Rollback();
                            Logger.TraceErrorFormat("Error while Saving {0}", response.ValidationResult.Errors);
                        }

                        return(response);
                    }

                    catch (Exception ex)
                    {
                        Logger.TraceError("Exception: ", ex);
                        transaction.Rollback();
                        throw;
                    }

                    finally
                    {
                        Logger.TraceMethodEnd(ClassName, "DeleteOrganizationConfirmed");
                    }
                }
            }
        }
Exemple #19
0
        public BugTrackingResponse <BusinessObjects.AspNetRole> Save(BusinessObjects.AspNetRole role)
        {
            Logger.TraceMethodStart(ClassName, "Save");

            var response = new BugTrackingResponse <BusinessObjects.AspNetRole>();


            using (var db = new EntityModel.BugTrackingEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var validator = new RoleSpecification();
                        var result    = validator.Validate(role);
                        var failures  = result.Errors;

                        response.ValidationResult = result;

                        if (result.IsValid)
                        {
                            role.Id           = Guid.NewGuid().ToString();
                            role.LastModified = DateTime.Now;
                            role.Active       = true;
                            var newrole = MapperAllLevels.Map <BusinessObjects.AspNetRole, EntityModel.AspNetRole>(role);
                            db.AspNetRoles.Add(newrole);
                            db.SaveChanges();
                            transaction.Commit();
                        }

                        else
                        {
                            transaction.Rollback();
                            Logger.TraceErrorFormat("Error while Saving {0}", response.ValidationResult.Errors);
                        }

                        return(response);
                    }

                    catch (Exception ex)
                    {
                        Logger.TraceError("Exception: ", ex);
                        transaction.Rollback();
                        throw;
                    }

                    finally
                    {
                        Logger.TraceMethodEnd(ClassName, "Save");
                    }
                }
            }
        }
        public BugTrackingResponse <BusinessObjects.ProductOrganisation> SaveProductOrganisation(BusinessObjects.ProductOrganisation productorganisation)
        {
            Logger.TraceMethodStart(ClassName, "SaveProductOrganisation");

            var response = new BugTrackingResponse <BusinessObjects.ProductOrganisation>();

            using (var db = new EntityModel.BugTrackingEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var validator = new ProdOrganizationSpecification();
                        var result    = validator.Validate(productorganisation);
                        var failures  = result.Errors;

                        response.ValidationResult = result;

                        if (result.IsValid)
                        {
                            productorganisation.Active       = true;
                            productorganisation.LastModified = DateTime.Now;
                            var productorg = MapperAllLevels.Map <BusinessObjects.ProductOrganisation, EntityModel.ProductOrganisation>(productorganisation);
                            db.ProductOrganisations.Add(productorg);
                            db.SaveChanges();
                            transaction.Commit();
                        }


                        else
                        {
                            transaction.Rollback();
                            Logger.TraceErrorFormat("Error while Saving {0}", response.ValidationResult.Errors);
                        }

                        return(response);
                    }

                    catch (Exception ex)
                    {
                        Logger.TraceError("Exception: ", ex);
                        transaction.Rollback();
                        throw;
                    }

                    finally
                    {
                        Logger.TraceMethodEnd(ClassName, "SaveProductOrganisation");
                    }
                }
            }
        }
Exemple #21
0
        public BugTrackingResponse <BusinessObjects.Category> SaveEdit(BusinessObjects.Category category)
        {
            Logger.TraceMethodStart(ClassName, "SaveEdit");

            var response = new BugTrackingResponse <BusinessObjects.Category>();

            using (var db = new EntityModel.BugTrackingEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var validator = new CategoryUpdateSpecification();
                        var result    = validator.Validate(category);
                        var failures  = result.Errors;

                        response.ValidationResult = result;

                        if (result.IsValid)
                        {
                            category.LastModified = DateTime.Now;
                            var newcat = MapperAllLevels.Map <BusinessObjects.Category, EntityModel.Category>(category);
                            db.Entry(newcat).State = EntityState.Modified;

                            db.SaveChanges();
                            transaction.Commit();
                        }

                        else
                        {
                            transaction.Rollback();
                            Logger.TraceErrorFormat("Error while Saving {0}", response.ValidationResult.Errors);
                        }

                        return(response);
                    }

                    catch (Exception ex)
                    {
                        Logger.TraceError("Exception: ", ex);
                        transaction.Rollback();
                        throw;
                    }

                    finally
                    {
                        Logger.TraceMethodEnd(ClassName, "SaveEdit");
                    }
                }
            }
        }
        public List <BusinessObjects.AspNetUser> GetRoleList()
        {
            Logger.TraceMethodStart(ClassName, "GetRoleList");
            var roles = default(List <BusinessObjects.AspNetUser>);

            try
            {
                using (var db = new EntityModel.BugTrackingEntities())
                {
                    var query = db.AspNetUsers.Where(c => c.Active == true)
                                .Include(x => x.Users)
                                .Include(x => x.AspNetUserRoles)

                                .ToList();



                    /*var query=from c in db.AspNetUsers
                     * join cr in db.Users on c.Id equals cr.UserId
                     * join r in db.AspNetUserRoles on c.Id equals r.UserId
                     * join k in db.AspNetRoles on r.RoleId equals k.Id
                     * where c.Active == true
                     * orderby c.UserName
                     * select new { FirstName = cr.FirstName, LastName = cr.LastName, Name = k.Name, Description = k.Description };
                     *
                     * var q = query.ToList();*/

                    roles = MapperAllLevels.Map <List <EntityModel.AspNetUser>, List <BusinessObjects.AspNetUser> >(query);

                    string json = JsonConvert.SerializeObject(roles, Formatting.Indented,
                                                              new JsonSerializerSettings {
                        PreserveReferencesHandling = PreserveReferencesHandling.Objects
                    });

                    Logger.LogDebug(json);
                    return(roles);
                }
            }
            catch (Exception ex)
            {
                Logger.TraceError("Exception:", ex);
                throw;
            }

            finally
            {
                Logger.TraceMethodEnd(ClassName, "GetRoleList");
            }
        }
        public void ActivateExistingUser(int Id)
        {
            Logger.TraceMethodStart(ClassName, "ActivateUser");



            using (var db = new EntityModel.BugTrackingEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var query = db.Users.Where(c => c.ID == Id && c.Active == false)
                                    .Include(x => x.AspNetUser)
                                    .SingleOrDefault()
                        ;

                        query.Active            = true;
                        query.AspNetUser.Active = true;

                        // var user = MapperAllLevels.Map<EntityModel.User, BusinessObjects.User>(query);

                        //db.Entry(user).State = EntityState.Modified;
                        db.SaveChanges();
                        transaction.Commit();
                    }

                    catch (Exception ex)
                    {
                        Logger.TraceError("Exception: ", ex);
                        transaction.Rollback();
                    }

                    finally
                    {
                        Logger.TraceMethodEnd(ClassName, "SaveAddInfo");
                    }
                }
            }
        }
        public void DeleteUserConfirmed(int Id)
        {
            Logger.TraceMethodStart(ClassName, "DeleteUserConfirmed");



            using (var db = new EntityModel.BugTrackingEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var query = db.Users.Where(c => c.ID == Id && c.Active == true)
                                    .Include(x => x.AspNetUser)
                                    .FirstOrDefault();

                        var user = MapperAllLevels.Map <EntityModel.User, BusinessObjects.User>(query);
                        //db.Users.Remove(query);
                        query.Active            = false;
                        query.LastModified      = DateTime.Now;
                        query.AspNetUser.Active = false;

                        db.SaveChanges();

                        transaction.Commit();
                    }

                    catch (Exception ex)
                    {
                        Logger.TraceError("Exception: ", ex);
                        transaction.Rollback();
                    }

                    finally
                    {
                        Logger.TraceMethodEnd(ClassName, "DeleteUserConfirmed");
                    }
                }
            }
        }
        public BugTrackingResponse <BusinessObjects.RegisterViewModel> SaveUser(BusinessObjects.RegisterViewModel Register)
        {
            Logger.TraceMethodStart(ClassName, "SaveUser");
            var response = new BugTrackingResponse <BusinessObjects.RegisterViewModel>();


            using (var db = new EntityModel.BugTrackingEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var validator = new RegisterSpecification();
                        var result    = validator.Validate(Register);
                        var failures  = result.Errors;

                        response.ValidationResult = result;

                        if (result.IsValid)
                        {
                            var usernamedata = db.AspNetUsers.Where(c => c.UserName == Register.Email && c.Active == true).SingleOrDefault();
                            var user         = MapperAllLevels.Map <BusinessObjects.RegisterViewModel, EntityModel.User>(Register);


                            user.Active          = true;
                            user.LastModified    = DateTime.Now;
                            user.UserId          = usernamedata.Id;
                            user.Email           = usernamedata.Email;
                            user.Username        = usernamedata.UserName;
                            user.FirstName       = Register.FirstName;
                            user.LastName        = Register.LastName;
                            user.OrganizationID  = Register.OrganizationID;
                            user.TelephoneNumber = Register.TelephoneNumber;

                            var userrole = MapperAllLevels.Map <BusinessObjects.RegisterViewModel, EntityModel.AspNetUserRole>(Register);
                            userrole.RoleId       = Register.RoleId;
                            userrole.UserId       = usernamedata.Id;
                            userrole.Active       = true;
                            userrole.LastModified = DateTime.Now;

                            db.AspNetUserRoles.Add(userrole);
                            db.Users.Add(user);

                            db.SaveChanges();
                            transaction.Commit();
                        }

                        else
                        {
                            transaction.Rollback();
                            Logger.TraceErrorFormat("Error while Saving {0}", response.ValidationResult.Errors);
                        }

                        return(response);
                    }



                    catch (Exception ex)
                    {
                        Logger.TraceError("Exception: ", ex);
                        transaction.Rollback();
                        throw;
                    }

                    finally
                    {
                        Logger.TraceMethodEnd(ClassName, "SaveAddInfo");
                    }
                }
            }
        }