public static void Reset()
 {
     _children   = null;
     _men        = null;
     _women      = null;
     _categories = null;
 }
Exemple #2
0
        public DTO.Category CreateCategory(DataAccess.Category category, bool includeOnlyActive = true)
        {
            CheckHelper.ArgumentNotNull(category, "category");
            CheckHelper.ArgumentWithinCondition(!category.IsNew(), "!category.IsNew()");

            return
                (_dtoCache.Get(
                     category,
                     c =>
            {
                var result =
                    new DTO.Category
                {
                    Id = c.Id,
                    Name = c.Name,
                    Active = c.Active
                };

                CopyTrackableFields(result, c);

                return result;
            },
                     (cDto, c) =>
                     cDto.SubCategories =
                         c.SubCategories
                         .Where(sc => sc.Active || !includeOnlyActive)
                         .OrderBy(sc => sc.Name)
                         .Select(sc => CreateSubCategory(sc, includeOnlyActive))
                         .ToArray()));
        }
Exemple #3
0
 private void LoadRecords()
 {
     dgDetails.Rows.Clear();
     eVariable.DisableGridColumnSort(dgDetails);
     if (oFindOption == FIND_OPTION.AUTHOR)
     {
         AuthorStructure();
         oAuthor = new DataAccess.Author();
         foreach (DataRow row in oAuthor.GetAuthor(cboSearch.Text, txtSearch.Text).Rows)
         {
             dgDetails.Rows.Add(row[0].ToString(), row[1].ToString(), row[2].ToString(), row[3].ToString(), row[4].ToString());
         }
     }
     else if (oFindOption == FIND_OPTION.CATEGORY)
     {
         CategoryStructure();
         oCategory = new DataAccess.Category();
         foreach (DataRow row in oCategory.GetCategory(cboSearch.Text, txtSearch.Text).Rows)
         {
             dgDetails.Rows.Add(row[0].ToString(), row[1].ToString(), row[2].ToString());
         }
     }
     else if (oFindOption == FIND_OPTION.LOCATION)
     {
         LocationStructure();
         oLocation = new DataAccess.Location();
         foreach (DataRow row in oLocation.GetLocationRecord(cboSearch.Text, txtSearch.Text).Rows)
         {
             dgDetails.Rows.Add(row[0].ToString(), row[1].ToString(), row[2].ToString());
         }
     }
 }
Exemple #4
0
 public static List<TbCategory> RetrieveUsedList()
 {
     using (DataAccess.Category db = new DataAccess.Category())
     {
         return db.RetrieveUsedList();
     }
 }
        public void CategoryControllerDetailsNotFoundIdFailureTest()
        {
            // Arrange
            DataAccess.Category expectedCategory = null;
            _categoryRepository.Setup(x => x.GetByIdAsync(It.IsAny <Guid>())).Returns(Task.FromResult(expectedCategory));

            // Act
            var categoryRequest   = _categoryController.Details(Guid.NewGuid().ToString("D"));
            var catNotFoundResult = categoryRequest.Result as NotFoundResult;

            // Assert
            catNotFoundResult.Should().NotBeNull("We expect that returned result will not be null.");
            catNotFoundResult.StatusCode.Should().Be((int)HttpStatusCode.NotFound, "Http code should be 404 Not Found.");
        }
Exemple #6
0
 public void LoadCategory()
 {
     try
     {
         oCategory = new DataAccess.Category();
         dgDetails.Rows.Clear();
         eVariable.DisableGridColumnSort(dgDetails);
         foreach (DataRow row in oCategory.GetCategory("", "").Rows)
         {
             dgDetails.Rows.Add(row[0], row[1], row[2]);
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemple #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            oMCategory = new Model.Category();
            oCategory  = new DataAccess.Category();

            if (eVariable.IsFieldEmpty(pnlBody))
            {
                oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.ALL_FIELDS_ARE_REQUIRED.ToString().Replace("_", " "));
                oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                oFrmMsgBox.ShowDialog();
                return;
            }

            if (eVariable.m_ActionType == eVariable.ACTION_TYPE.EDIT)
            {
                oMCategory.CATEGORY_ID = eVariable.sUniqueID;
                oMCategory.CATEGORY    = txtCategory.Text;
                oMCategory.STATUS      = chkActive.Checked == true ? "ACTIVE" : "INACTIVE";
                oCategory.UpdateCategory(oMCategory);
            }
            else
            {
                oMCategory.CATEGORY = txtCategory.Text;
                oMCategory.STATUS   = chkActive.Checked == true ? "ACTIVE" : "INACTIVE";

                if (oCategory.isRecordExists(oMCategory))
                {
                    oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.RECORD_IS_ALREADY_EXISTS.ToString().Replace("_", " "));
                    oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    return;
                }

                oCategory.InsertCategory(oMCategory);
            }

            oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.RECORD_HAS_BEEN_SUCESSFULLY_SAVED.ToString().Replace("_", " "));
            oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
            oFrmMsgBox.ShowDialog();
            eVariable.ClearText(pnlBody);
            eVariable.m_ActionType = eVariable.ACTION_TYPE.ADD;
            LoadCategory();
        }
Exemple #8
0
        public void CreateCategory(DTO.Category createdCategory)
        {
            CheckHelper.ArgumentNotNull(createdCategory, "createdCategory");
            CheckHelper.ArgumentWithinCondition(createdCategory.IsNew(), "Category is not new.");
            Container.Get <IValidateService>().CheckIsValid(createdCategory);

            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in.");
            CheckHelper.WithinCondition(SecurityService.IsCurrentUserSeller, "Only seller can create category.");

            var persistentService = Container.Get <IPersistentService>();

            var doesAnotherCategoryWithTheSameNameExist =
                persistentService
                .GetEntitySet <DataAccess.Category>()
                .Any(c => c.Name == createdCategory.Name);

            if (doesAnotherCategoryWithTheSameNameExist)
            {
                throw new CategoryServiceException("Категория с заданным названием уже существует.");
            }

            var category =
                new DataAccess.Category
            {
                Name   = createdCategory.Name,
                Active = createdCategory.Active
            };

            category.UpdateTrackFields(Container);
            persistentService.Add(category);

            persistentService.SaveChanges();

            createdCategory.Id         = category.Id;
            createdCategory.CreateDate = category.CreateDate;
            createdCategory.CreateUser = category.CreatedBy.GetFullName();
            createdCategory.ChangeDate = category.ChangeDate;
            createdCategory.ChangeUser = category.ChangedBy.GetFullName();
        }
        public void CategoryControllerDetailsFoundTest()
        {
            // Arrange
            var expectedCategory = new DataAccess.Category
            {
                Id           = Guid.NewGuid(),
                CategoryName = "test cat 200",
                Products     = new Mock <ICollection <Product> >().Object
            };

            _categoryRepository.Setup(x => x.GetByIdAsync(It.IsAny <Guid>())).Returns(Task.FromResult(expectedCategory));

            // Act
            var categoryRequest = _categoryController.Details(expectedCategory.Id.ToString("D"));
            var categoryModel   = categoryRequest.Result as OkObjectResult;

            // Assert
            var catModel = categoryModel.Value as Models.Category;

            catModel.Should().NotBeNull("We expect that returned category will be not null.");

            catModel.CategoryName.Should().Be(expectedCategory.CategoryName, "Category name must be equal to mock cat name.");
            catModel.CategoryId.Should().Be(expectedCategory.Id, "Category id must be equal to mock cat id.");
        }