Beispiel #1
0
        public override DbOperationResultViewModel Update(string entityStr)
        {
            var result = this.CreateReponse();
            var model  = JsonConvert.DeserializeObject <Product>(entityStr);
            var entity = _repository.SingleOrDefault(p => p.Id == model.Id, disableTracking: false);

            if (entity != null)
            {
                entity = _mapper.Map(model, entity);
                var productImageRepository = this.UnitOfWork.Repository <Product_Image>();
                var productPriceRepository = this.UnitOfWork.Repository <Product_Price>();
                var imageRepository        = this.UnitOfWork.Repository <NTImage>();
                var priceRepository        = this.UnitOfWork.Repository <NTPrice>();

                foreach (var product_image in productImageRepository.Local(EntityState.Deleted))
                {
                    imageRepository.Remove(product_image.ImageId);
                }

                foreach (var product_price in productPriceRepository.Local(EntityState.Deleted))
                {
                    imageRepository.Remove(product_price.PriceId);
                }
                this.UnitOfWork.Commit();
            }
            else
            {
                result.ErrorMsg = $"Id: {model.Id} not found";
            }
            return(result);
        }
        public Parameter Find(string parameterName)
        {
            Parameter result = null;

            RetryableOperation.Invoke(ExceptionPolicies.General, () => { result = _repository.SingleOrDefault(x => x.ParameterName == parameterName); });
            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// Validate a forgot password request
        /// </summary>
        /// <param name="link">Link of the request</param>
        /// <returns>Email Address if request is valid, otherwise nothing.</returns>
        public bool ValidateForgotPasswordRequest(string link)
        {
            var forgotPasswordRequest = _forgotPasswordRequestsRepository.SingleOrDefault(s => s.Link == link);
            var datesDifference       = DateTime.UtcNow - forgotPasswordRequest.DateCreatedUtc;

            return(datesDifference.TotalHours <= 24);
        }
Beispiel #4
0
        public Like AddLike(AspNetUser user, Article article)
        {
            return(Decorator(() =>
            {
                ApplicationRule a = new ApplicationRule(this, _userRepo.SingleOrDefault(u => u.Id == user.Id) != null, ReasonEnum.NoUSer);
                ApplicationRule b = new ApplicationRule(this, _articleRepo.SingleOrDefault(art => art.Id == article.Id) != null, ReasonEnum.NoArticle);
                int likesPerUser = _likeRepo.Read(l => l.UserId == user.Id).Count();
                ApplicationRule c = new ApplicationRule(this, likesPerUser < Settings.Default.MaxLikes, ReasonEnum.MaxLikes);
                ApplicationRule d = new ApplicationRule(this, _likeRepo.SingleOrDefault(l => l.UserId == user.Id && l.ArticleId == article.Id) == null, ReasonEnum.AlreadyLiked);

                if (a & b & c & d)
                {
                    Like like = _likeRepo.Create();
                    like.UserId = user.Id;
                    like.ArticleId = article.Id;
                    like.CreatedDate = DateTime.Now;
                    _likeRepo.Add(like);
                    return like;
                }
                else
                {
                    return null;
                }
            }));
        }
Beispiel #5
0
        public async Task SingleOrDefault_ShouldGetTheFirstById()
        {
            var expected = OriginalAbstractSyntaxTreeMetrics[0].Id;

            var actual = await Repository.SingleOrDefault(e => e.Id.Equals(expected));

            Assert.IsNotNull(actual);
        }
Beispiel #6
0
        public void Should_Delete_Product()
        {
            var prod = _repository.SingleOrDefault(x => x.Id == 1);

            _repository.Delete(prod);
            _unitOfWork.Commit();

            prod = _repository.SingleOrDefault(x => x.Id == 1);
            prod.ShouldBeNull();
        }
        private User Handle(GetUser request)
        {
            var user = _repository.SingleOrDefault <Domain.User>(x => x.Id == request.Id);

            if (user == null)
            {
                throw new HypermediaEngineException(new NotFoundResponse(Context));
            }

            return(new User(Context, user));
        }
Beispiel #8
0
        public void CreateBlogPostCategory(BlogPostCategory category)
        {
            var checkCategory = _blogPostCategoriesRepository.SingleOrDefault(c => c.Slug == category.Slug);

            if (checkCategory != null)
            {
                throw new ArgumentException("A blog post category already exists for the specified slug");
            }

            _blogPostCategoriesRepository.Create(category);
        }
        public void UdpateDetails(string id, JobStatusDetails details)
        {
            var deployment = _repository.SingleOrDefault(d => d.Id == id);

            if (deployment != null)
            {
                if (string.IsNullOrWhiteSpace(deployment.Details))
                {
                    deployment.Details += details.Details;
                }
                else
                {
                    deployment.Details += "<br>" + details.Details;
                }

                if (details.Status.HasValue)
                {
                    deployment.Status = details.Status.Value.ToString();
                }

                if (details.Status == JobStatus.Error && deployment.UserEmail.HasValue() && _sourceControl.IsVersionNumber(deployment.Revision))
                {
                    _emailSender.SendDeploymentWarningEmail(deployment.Details, deployment.Revision.Tag, deployment.Company.CompanyName, deployment.UserName, deployment.UserEmail, deployment.Server.Name);
                }

                _repository.Update(deployment);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Inserts an activity log item
        /// </summary>
        /// <param name="user">The user who's activity is being logged</param>
        /// <param name="systemKeyword">The system keyword</param>
        /// <param name="comment">The activity comment</param>
        /// <param name="commentParams">The activity comment parameters for string.Format() function.</param>
        /// <returns>Activity log item</returns>
        public ActivityLog InsertActivity(Person user, string systemKeyword, string comment = "",
                                          params object[] commentParams)
        {
            if (user == null)
            {
                return(null);
            }

            var activityType = _activityLogTypeRepository.SingleOrDefault(a => a.SystemKeyword == systemKeyword);

            //if (activityType == null || !activityType.Enabled)
            //return null;

            comment = CommonHelper.EnsureNotNull(comment);
            comment = string.Format(comment, commentParams);
            comment = CommonHelper.EnsureMaximumLength(comment, maxLength: 4000);

            var activityLog = new ActivityLog()
            {
                ActivityLogTypeId = activityType.ActivityLogTypeId,
                PersonId          = user.BusinessEntityId,
                Comment           = comment,
                DateCreatedUtc    = DateTime.UtcNow,
                IpAddress         = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString(),
            };

            _customerActivityRepository.Create(activityLog);

            return(activityLog);
        }
Beispiel #11
0
        public PSTutorialFlags(account account, IRepository<character_tutorial> characterTutorials)
            : base(WorldOpcodes.SMSG_TUTORIAL_FLAGS)
        {
            character_tutorial characterTutorial = characterTutorials.SingleOrDefault(ct => ct.account == account.id);

            if (characterTutorial == null)
            {
                characterTutorial = new character_tutorial()
                                        {
                                            account = account.id,
                                            tut0 = 0,
                                            tut1 = 0,
                                            tut2 = 0,
                                            tut3 = 0,
                                            tut4 = 0,
                                            tut5 = 0,
                                            tut6 = 0,
                                            tut7 = 0
                                        };
                characterTutorials.Add(characterTutorial);
            }

            this.Write((byte)characterTutorial.tut0);
            this.Write((byte)characterTutorial.tut1);
            this.Write((byte)characterTutorial.tut2);
            this.Write((byte)characterTutorial.tut3);
            this.Write((byte)characterTutorial.tut4);
            this.Write((byte)characterTutorial.tut5);
            this.Write((byte)characterTutorial.tut6);
            this.Write((byte)characterTutorial.tut7);
        }
        private dynamic Handle(PostLogin request)
        {
            var user = _repository.SingleOrDefault <User>(x => x.Username.ToLower() == request.Username.ToLower());

            if (user == null || user.Validate(request.Password) == false)
            {
                return(Response.AsJson(new LoginFailed(Context))
                       .WithContentType("application/vnd.siren+json; charset=utf-8"));
            }

            var accessToken = user.IssueAccessToken();

            _repository.SaveOrUpdate(user);

            return(new LoginSuccess(Context, accessToken));
        }
        public async Task <LoginResponseModel> Handle(LoginRequestModel request, CancellationToken cancellationToken)
        {
            var customer = _customerRepo.SingleOrDefault(c => c.Email == request.Email);

            if (customer == null)
            {
                throw new ArgumentException("Invalid login credentials");
            }
            var passwordHasher  = new PasswordHasher <Customer>();
            var isPasswordValid = passwordHasher.VerifyHashedPassword(customer, customer.Password, request.Password);

            if (isPasswordValid == PasswordVerificationResult.Failed)
            {
                throw new ArgumentException("Invalid login credentials");
            }
            else if (customer.Status != ECustomerStatus.ACTIVE)
            {
                throw new ArgumentException("Customer account has been suspended");
            }

            var response = _mapper.Map <LoginResponseModel>(customer);

            response.Token = JWTHelper.GetJWTToken(customer);
            return(response);
        }
Beispiel #14
0
        public PSTutorialFlags(account account, IRepository <character_tutorial> characterTutorials)
            : base(WorldOpcodes.SMSG_TUTORIAL_FLAGS)
        {
            character_tutorial characterTutorial = characterTutorials.SingleOrDefault(ct => ct.account == account.id);

            if (characterTutorial == null)
            {
                characterTutorial = new character_tutorial()
                {
                    account = account.id,
                    tut0    = 0,
                    tut1    = 0,
                    tut2    = 0,
                    tut3    = 0,
                    tut4    = 0,
                    tut5    = 0,
                    tut6    = 0,
                    tut7    = 0
                };
                characterTutorials.Add(characterTutorial);
            }

            this.Write((byte)characterTutorial.tut0);
            this.Write((byte)characterTutorial.tut1);
            this.Write((byte)characterTutorial.tut2);
            this.Write((byte)characterTutorial.tut3);
            this.Write((byte)characterTutorial.tut4);
            this.Write((byte)characterTutorial.tut5);
            this.Write((byte)characterTutorial.tut6);
            this.Write((byte)characterTutorial.tut7);
        }
Beispiel #15
0
        public void AddAndUpdateAndDelete()
        {
            var name     = string.Format("Category{0}", new Random().Next(100000));
            var category = new Category
            {
                Name = name
            };

            _categoryRepository.Save(category);

            var createdCategory = _categoryRepository.SingleOrDefault(i => i.Name.Equals(name));

            Assert.IsNotNull(createdCategory);
            Assert.IsTrue(createdCategory.Id > 0);

            var newName = name.Replace("Category", "CategoryUpdated");

            createdCategory.Name = newName;

            _categoryRepository.Save(createdCategory);

            Assert.IsFalse(_categoryRepository.Any(i => i.Name.Equals(name)));
            Assert.IsTrue(_categoryRepository.Any(i => i.Name.Equals(newName)));

            _categoryRepository.Delete(createdCategory);

            Assert.IsFalse(_categoryRepository.Any(i => i.Name.Equals(name) || i.Name.Equals(newName)));
        }
        public void Test()
        {
            Assert.False(_testProductRepo.Any());

            var product = new TestProduct
            {
                Name        = "Fristi Milk",
                Description = "Orange Flavor",
                Price       = 10000
            };

            _testProductRepo.Add(product);

            Assert.True(_testProductRepo.Any());
            Assert.NotNull(product.Id);

            var alreadyAddedProduct = _testProductRepo.SingleOrDefault(c => c.Name == "Fristi Milk");

            Assert.NotNull(alreadyAddedProduct);
            Assert.Equal(product.Id, alreadyAddedProduct.Id);

            alreadyAddedProduct.Description = "Lemon Flavor";
            _testProductRepo.Update(alreadyAddedProduct);
            var updatedProduct = _testProductRepo.GetById(product.Id);

            Assert.NotNull(updatedProduct);
            Assert.Equal(product.Id, updatedProduct.Id);
            Assert.Equal("Lemon Flavor", updatedProduct.Description);
        }
Beispiel #17
0
        /// <summary>
        /// Gets a setting
        /// </summary>
        /// <param name="key">Key of the setting</param>
        /// <returns>Setting associated with the specified key</returns>
        public Setting GetSettingByKey(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentException("Setting key cannot be null or empty.", nameof(key));
            }

            var setting = _settingRepository.SingleOrDefault(s => s.Name == key);

            if (setting == null)
            {
                throw new ArgumentException($"No setting found for specified key = {key}", nameof(key));
            }

            return(setting);
        }
        public override Money CalculateTax(EntitiesV2.Product product, EntitiesV2.PriceGroup priceGroup, Money unitPrice)
        {
            var productProperty = product.GetProperties()
                                  .FirstOrDefault(x => x.GetDefinitionField().DataType.DefinitionName == "PriceGroup");

            if (productProperty == null && product.ParentProduct != null)
            {
                // check variant
                productProperty = product.ParentProduct
                                  .GetProperties()
                                  .FirstOrDefault(x => x.GetDefinitionField().DataType.DefinitionName == "PriceGroup");
            }

            if (productProperty == null)
            {
                return(base.CalculateTax(product, priceGroup, unitPrice));
            }

            int priceGroupId = -1;

            if (int.TryParse(productProperty.GetValue().ToString(), out priceGroupId))
            {
                var overridenPriceGroup = _priceGroupRepository.SingleOrDefault(x => x.PriceGroupId == priceGroupId);
                if (priceGroup != null)
                {
                    return(CalculateTax(overridenPriceGroup, unitPrice));
                }
            }

            return(base.CalculateTax(product, priceGroup, unitPrice));
        }
        public async Task <FundWalletResponseModel> Handle(FundWalletRequestModel request, CancellationToken cancellationToken)
        {
            if (request.Amount < 1)
            {
                throw new ArgumentException("Minimum allowed deposit amount is 1");
            }
            var wallet = _walletRepo.SingleOrDefault(w => w.AccountNumber == request.AccountNumber);

            if (wallet == null)
            {
                throw new ArgumentException("Invalid wallet account number");
            }
            var trans = new WalletTransaction
            {
                AccountNumber    = request.AccountNumber,
                Amount           = request.Amount,
                BalanceAfter     = wallet.Balance + request.Amount,
                BalanceBefore    = wallet.Balance,
                CustomerId       = WebHelper.CurrentCustomerId,
                Description      = request.Description,
                Id               = Guid.NewGuid(),
                Status           = EWalletTransactionStatus.APPROVED,
                TransReferenceId = request.TransReference,
                Type             = EWalletTransactionType.DEPOSIT
            };
            await _walletTransRepo.AddAsync(trans);

            wallet.Balance += request.Amount;
            _walletRepo.Update(wallet);
            var response = _mapper.Map <FundWalletResponseModel>(trans);

            response.Label = wallet.Label;
            return(response);
        }
Beispiel #20
0
        /* Method which displays the menu to the student */
        public ActionResult Index()                                                                            // Index Page
        {
            string  username = User.Identity.Name;                                                             // Gets the current logged in user
            Student student  = _repository.SingleOrDefault <Student>(s => s.UserProfile.UserName == username); // retrieves the user from the student repository

            return(View(student));                                                                             // passes the student object to the view
        }
Beispiel #21
0
        public ActionResult SaveReview(ReviewFormSaveReviewViewModel viewModel)
        {
            var product = _productRepository.SingleOrDefault(x => x.Guid.ToString() == viewModel.ProductGuid);

            var catalogGroup   = _catalogContext.CurrentCatalogGroup;
            var catalogGroupV2 = ProductCatalogGroup.FirstOrDefault(x => x.Guid == catalogGroup.Guid);

            var request = System.Web.HttpContext.Current.Request;
            var basket  = _orderContext.GetBasket();

            var name           = viewModel.Name;
            var email          = viewModel.Email;
            var rating         = viewModel.Rating * 20;
            var reviewHeadline = viewModel.Title;
            var reviewText     = viewModel.Comments;

            if (basket.PurchaseOrder.Customer == null)
            {
                basket.PurchaseOrder.Customer = new Customer()
                {
                    FirstName    = name,
                    LastName     = String.Empty,
                    EmailAddress = email
                };
            }
            else
            {
                basket.PurchaseOrder.Customer.FirstName = name;
                if (basket.PurchaseOrder.Customer.LastName == null)
                {
                    basket.PurchaseOrder.Customer.LastName = String.Empty;
                }
                basket.PurchaseOrder.Customer.EmailAddress = email;
            }

            basket.PurchaseOrder.Customer.Save();

            var review = new ProductReview();

            review.ProductCatalogGroup = catalogGroupV2;
            review.ProductReviewStatus = _productReviewStatusRepository.SingleOrDefault(s => s.Name == "New");
            review.CreatedOn           = DateTime.Now;
            review.CreatedBy           = "System";
            review.Product             = product;
            review.Customer            = basket.PurchaseOrder.Customer;
            review.Rating         = rating;
            review.ReviewHeadline = reviewHeadline;
            review.ReviewText     = reviewText;
            review.Ip             = request.UserHostName;

            product.AddProductReview(review);

            _productReviewPipeline.Execute(review);


            return(Json(new { Rating = review.Rating, ReviewHeadline = review.ReviewHeadline, CreatedBy = review.CreatedBy, CreatedOn = review.CreatedOn.ToString("MMM dd, yyyy"), CreatedOnForMeta = review.CreatedOn.ToString("yyyy-MM-dd"), Comments = review.ReviewText }, JsonRequestBehavior.AllowGet));
        }
Beispiel #22
0
        public Course Get(int id)
        {
            var result = new Course();

            try
            {
                using (var ctx = _dbContextScopeFactory.Create())
                {
                    result = _courseRepository.SingleOrDefault(x => x.Id == id);
                }
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
            }

            return(result);
        }
Beispiel #23
0
        public async Task <PlaygroundDto> GetPlaygroundById(int playgroundId)
        {
            var playground = await _playgroundRepository.SingleOrDefault(
                predicate : p => p.Id == playgroundId,
                includeProperties : new Expression <Func <Playground, object> >[]
                { (p => p.Location), (p => p.Photos) });

            return(_mapper.Map <PlaygroundDto>(playground));
        }
        public void SingleTest()
        {
            var customers = new List <TestCustomer>
            {
                new TestCustomer {
                    FirstName = "Customer A"
                },
                new TestCustomer {
                    FirstName = "Client B"
                },
                new TestCustomer {
                    FirstName = "Customer C"
                },
                new TestCustomer {
                    FirstName = "Client D"
                },
                new TestCustomer {
                    FirstName = "Customer E"
                },
                new TestCustomer {
                    FirstName = "Client F"
                },
                new TestCustomer {
                    FirstName = "Customer G"
                }
            };

            _testCustomerRepo.Add(customers);

            var cutomer = _testCustomerRepo.SingleOrDefault(s => s.FirstName == "Customer A");

            _testCustomerRepo.Delete(cutomer);
            cutomer = _testCustomerRepo.SingleOrDefault(s => s.Id == cutomer.Id);

            Assert.Null(cutomer);

            cutomer = _testCustomerRepo.SingleOrDefault(s => s.FirstName == "Client B");
            _testCustomerRepo.Delete(cutomer.Id);
            cutomer = _testCustomerRepo.SingleOrDefault(s => s.Id == cutomer.Id);

            Assert.Null(cutomer);

            _testCustomerRepo.DeleteAll();
        }
 public void Delete(int id)
 {
     DAL.DataEntities.CustomRule customRule;
     using (_CustomRuleRepository = new GenericRepository<DAL.DataEntities.CustomRule>())
     {
         customRule = _CustomRuleRepository.SingleOrDefault(m => m.ID == id);
         _CustomRuleRepository.Delete(customRule);
         _CustomRuleRepository.SaveChanges();
     }
 }
 public void Delete(int id)
 {
     DAL.DataEntities.CompositionRule feature;
     using (_CompositionRuleRepository = new GenericRepository<DAL.DataEntities.CompositionRule>())
     {
         feature = _CompositionRuleRepository.SingleOrDefault(m => m.ID == id);
         _CompositionRuleRepository.Delete(feature);
         _CompositionRuleRepository.SaveChanges();
     }
 }
 public void Delete(int id)
 {
     DAL.DataEntities.UITemplate template;
     using (_UITemplateRepository = new GenericRepository<DAL.DataEntities.UITemplate>())
     {
         template = _UITemplateRepository.SingleOrDefault(m => m.ID == id);
         _UITemplateRepository.Delete(template);
         _UITemplateRepository.SaveChanges();
     }
 }
 public void Delete(int id)
 {
     DAL.DataEntities.Attribute attribute;
     using (_AttributeRepository = new GenericRepository<DAL.DataEntities.Attribute>())
     {
         attribute = _AttributeRepository.SingleOrDefault(m => m.ID == id);
         _AttributeRepository.Delete(attribute);
         _AttributeRepository.SaveChanges();
     }
 }
 public void Delete(int id)
 {
     DAL.DataEntities.Model model;
     using (_ModelRepository = new GenericRepository<DAL.DataEntities.Model>())
     {
         model = _ModelRepository.SingleOrDefault(m => m.ID == id);
         _ModelRepository.Delete(model);
         _ModelRepository.SaveChanges();
     }
 }
Beispiel #30
0
        public async Task <FindTransactionResponseModel> Handle(FindTransactionRequestModel request, CancellationToken cancellationToken)
        {
            var trans = _walletTransRepo.SingleOrDefault(t => t.Id == request.TransId && t.CustomerId == WebHelper.CurrentCustomerId);

            if (trans == null)
            {
                throw new ArgumentException("Transaction not found");
            }
            return(_mapper.Map <FindTransactionResponseModel>(trans));
        }
 public void Delete(int id)
 {
     DAL.DataEntities.Configuration DALConfiguration;
     using (_ConfigurationRepository = new GenericRepository<DAL.DataEntities.Configuration>())
     {
         DALConfiguration = _ConfigurationRepository.SingleOrDefault(m => m.ID == id);
         _ConfigurationRepository.Delete(DALConfiguration);
         _ConfigurationRepository.SaveChanges();
     }
 }
        public ServiceDesk GetByCustomerAndId(int customerId, int id)
        {
            ServiceDesk result = null;

            RetryableOperation.Invoke(ExceptionPolicies.General, () =>
            {
                result = _serviceDeskRepository.SingleOrDefault(x => x.CustomerId == customerId && x.Id == id);
            });
            return(result);
        }
Beispiel #33
0
        public IHttpActionResult Get(Guid id)
        {
            var customer = _customerRepository.SingleOrDefault(c => c.Id == id);

            if (customer == null)
            {
                return(NotFound());
            }

            return(Ok(_viewModelFactory.Create(customer, null)));
        }
Beispiel #34
0
        private ProductOption TryGetProductOption(Guid productId, Guid id)
        {
            var productOption = _productOptions.SingleOrDefault(po => po.ProductId == productId && po.Id == id);

            if (productOption == null)
            {
                ThrowNotFoundException();
            }

            return(productOption);
        }
Beispiel #35
0
        /// <summary>
        /// Gets a TermRelationship
        /// </summary>
        /// <param name="guid">Guid of the term relationship</param>
        /// <returns>TermRelationship associated with the specified guid</returns>
        public TermRelationship GetTermRelationshipByGuid(Guid guid)
        {
            var termRelationship = _termRelationshipRepository.SingleOrDefault(t => t.RowGuid == guid);

            if (termRelationship == null)
            {
                throw new ArgumentException($"No term relationship found for specified guid = {guid}", nameof(guid));
            }

            return(termRelationship);
        }
Beispiel #36
0
        public virtual ConfirmationEmailViewModel GetViewModel(string orderGuid)
        {
            var confirmationEmailViewModel = new ConfirmationEmailViewModel();

            if (!string.IsNullOrWhiteSpace(orderGuid))
            {
                var purchaseOrder = _purchaseOrderRepository.SingleOrDefault(x => x.OrderGuid == new Guid(orderGuid));
                confirmationEmailViewModel = MapPurchaseOrder(purchaseOrder, confirmationEmailViewModel);
            }
            return(confirmationEmailViewModel);
        }
        public void GetTest()
        {
            var customer = _testCustomerRepo.SingleOrDefault(s => s.FirstName == "Customer A");

            Assert.NotNull(customer);
            Assert.Equal("Customer A", customer.FirstName);

            var customer1 = _testCustomerRepo.GetById(customer.Id);

            Assert.NotNull(customer1);
            Assert.Equal(customer.Id, customer1.Id);
        }
 //Methods
 public BLL.BusinessObjects.User GetByEmailAndPassword(string email, string password)
 {
     DAL.DataEntities.User user;
     using (_UserRepository = new GenericRepository<DAL.DataEntities.User>())
     {
         user = _UserRepository.SingleOrDefault(u =>
             u.Email.Equals(email, StringComparison.InvariantCultureIgnoreCase) && u.Password.Equals(password, StringComparison.InvariantCultureIgnoreCase));
     }
     //
     if (user != null)
         return (BLL.BusinessObjects.User)BLL.BusinessObjects.User.CreateInstance(user);
     else
         return null;
 }
 public BLL.BusinessObjects.UITemplate GetByID(int id)
 {
     DAL.DataEntities.UITemplate uiTemplate;
     using (_UITemplateRepository = new GenericRepository<DAL.DataEntities.UITemplate>())
     {
         uiTemplate = _UITemplateRepository.SingleOrDefault(u => u.ID == id);
     }
     //
     return new BLL.BusinessObjects.UITemplate(uiTemplate);
 }
 public BusinessObjects.Model GetByID(int id)
 {
     BLL.BusinessObjects.Model BLLmodel;
     using (_ModelRepository = new GenericRepository<DAL.DataEntities.Model>())
     {
         DAL.DataEntities.Model DALmodel = _ModelRepository.SingleOrDefault(m => m.ID == id);
         BLLmodel = BLL.BusinessObjects.Model.CreateInstance(DALmodel);
     }
     //
     return BLLmodel;
 }
        public void UpdateName(int modelID, string newName)
        {
            using (_ModelRepository = new GenericRepository<DAL.DataEntities.Model>())
            {
                DAL.DataEntities.Model model = _ModelRepository.SingleOrDefault(m => m.ID == modelID);
                model.LastModifiedDate = DateTime.Now;
                model.Name = newName;

                //_ModelRepository.Attach(model);
                _ModelRepository.SaveChanges();
            }
        }
 public BLL.BusinessObjects.User GetByID(int id)
 {
     DAL.DataEntities.User user;
     using (_UserRepository = new GenericRepository<DAL.DataEntities.User>())
     {
         user = _UserRepository.SingleOrDefault(u => u.ID == id);
     }
     //
     return new BLL.BusinessObjects.User(user);
 }
 public BusinessObjects.Configuration GetByID(int id)
 {
     BLL.BusinessObjects.Configuration BLLConfiguration;
     using (_ConfigurationRepository = new GenericRepository<DAL.DataEntities.Configuration>())
     {
         DAL.DataEntities.Configuration DALConfiguration = _ConfigurationRepository.SingleOrDefault(m => m.ID == id);
         BLLConfiguration = BLL.BusinessObjects.Configuration.CreateInstance(DALConfiguration);
     }
     //
     return BLLConfiguration;
 }
 public void Delete(int id)
 {
     DAL.DataEntities.Relation relation;
     using (_RelationRepository = new GenericRepository<DAL.DataEntities.Relation>())
     {
         relation = _RelationRepository.SingleOrDefault(m => m.ID == id);
         _RelationRepository.Delete(relation);
         _RelationRepository.SaveChanges();
     }
 }
 public BusinessObjects.Feature GetByID(int id)
 {
     DAL.DataEntities.Feature feature;
     using (_FeatureRepository = new GenericRepository<DAL.DataEntities.Feature>())
     {
         feature = _FeatureRepository.SingleOrDefault(m => m.ID == id);
     }
     //
     return new BLL.BusinessObjects.Feature(feature);
 }
 public void Delete(int id)
 {
     DAL.DataEntities.FeatureSelection feature;
     using (_FeatureSelectionRepository = new GenericRepository<DAL.DataEntities.FeatureSelection>())
     {
         feature = _FeatureSelectionRepository.SingleOrDefault(m => m.ID == id);
         _FeatureSelectionRepository.Delete(feature);
         _FeatureSelectionRepository.SaveChanges();
     }
 }
 public BusinessObjects.Attribute GetByID(int id)
 {
     DAL.DataEntities.Attribute attribute;
     using (_AttributeRepository = new GenericRepository<DAL.DataEntities.Attribute>())
     {
         attribute = _AttributeRepository.SingleOrDefault(m => m.ID == id);
     }
     //
     return new BLL.BusinessObjects.Attribute(attribute);
 }
        public void Delete(int id)
        {
            DAL.DataEntities.Feature feature;
            using (_FeatureRepository = new GenericRepository<DAL.DataEntities.Feature>())
            {
                feature = _FeatureRepository.SingleOrDefault(m => m.ID == id);

                //Cascade delete on all related FeatureSelections
                using (_FeatureSelectionRepository = new GenericRepository<DAL.DataEntities.FeatureSelection>())
                {
                    IEnumerable<DAL.DataEntities.FeatureSelection> featureSelections = _FeatureSelectionRepository.Find(k => k.FeatureID == feature.ID);
                    foreach (DAL.DataEntities.FeatureSelection featureSelection in featureSelections)
                    {
                        _FeatureSelectionRepository.Delete(featureSelection);
                    }

                    _FeatureSelectionRepository.SaveChanges();
                }

                //
                _FeatureRepository.Delete(feature);
                _FeatureRepository.SaveChanges();
            }
        }
 public BusinessObjects.Relation GetByID(int id)
 {
     DAL.DataEntities.Relation relation;
     using (_RelationRepository = new GenericRepository<DAL.DataEntities.Relation>())
     {
         relation = _RelationRepository.SingleOrDefault(r => r.ID == id);
     }
     //
     return new BLL.BusinessObjects.Relation(relation);
 }
 public void Delete(int id)
 {
     //Delete GroupRelation
     DAL.DataEntities.GroupRelation groupRelation;
     using (_GroupRelationRepository = new GenericRepository<DAL.DataEntities.GroupRelation>())
     {
         groupRelation = _GroupRelationRepository.SingleOrDefault(m => m.ID == id);
         _GroupRelationRepository.Delete(groupRelation);
         _GroupRelationRepository.SaveChanges();
     }
 }
        public void UpdateName(int configurationID, string newName)
        {
            using (_ConfigurationRepository = new GenericRepository<DAL.DataEntities.Configuration>())
            {
                DAL.DataEntities.Configuration model = _ConfigurationRepository.SingleOrDefault(m => m.ID == configurationID);
                model.LastModifiedDate = DateTime.Now;
                model.Name = newName;

                _ConfigurationRepository.SaveChanges();
            }
        }
        public DocumentContext(int id, IRepository repository)
        {
            _repository = repository;

            _commentDocument = repository.SingleOrDefault<CommentDocument>(p => p.Id == id);
        }
 public BusinessObjects.CustomRule GetByID(int id)
 {
     DAL.DataEntities.CustomRule customRule;
     using (_CustomRuleRepository = new GenericRepository<DAL.DataEntities.CustomRule>())
     {
         customRule = _CustomRuleRepository.SingleOrDefault(m => m.ID == id);
     }
     //
     return new BLL.BusinessObjects.CustomRule(customRule);
 }