public ActionResult SaveItemCategory(ItemCategoryDTO Ic)
        {
            Ic.statusid  = 1;
            Ic.createdby = Convert.ToInt64(Session["UserId"]);
            int isSaved = posMasters.SaveItemCategory(Ic);

            return(new JsonResult {
                Data = isSaved, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public void Edited(ItemCategoryDTO obj)
        {
            ItemCategory EditedCategory = _db.ItemCategories.Where(x => x.ItemCategoryId == obj.ItemCategoryId).FirstOrDefault();

            EditedCategory.ItemCategoryId   = obj.ItemCategoryId;
            EditedCategory.ItemCategoryName = obj.ItemCategoryName;
            EditedCategory.SignUpId         = obj.SignUpId;
            _db.Entry(EditedCategory).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            _db.SaveChanges();
        }
Exemple #3
0
 public static void ConvertToItemCategoryEntity(ref ItemCategory item, ItemCategoryDTO itemDTO, bool isUpdate)
 {
     if (isUpdate)
     {
         item.ItemId = itemDTO.ItemId;
     }
     item.ItemCode        = itemDTO.ItemCode;
     item.ItemName        = itemDTO.ItemName;
     item.ItemDescription = itemDTO.ItemDescription;
 }
        public void Created(ItemCategoryDTO obj)
        {
            ItemCategory Create = new ItemCategory();

            Create.ItemCategoryName = obj.ItemCategoryName;
            Create.SignUpId         = obj.SignUpId;

            _db.Add(Create);
            _db.SaveChanges();
        }
Exemple #5
0
        public static ItemCategoryDTO ConvertToItemCategoryDto(ItemCategory item)
        {
            ItemCategoryDTO itemDTO = new ItemCategoryDTO();

            itemDTO.ItemId          = item.ItemId;
            itemDTO.ItemCode        = item.ItemCode;
            itemDTO.ItemName        = item.ItemName;
            itemDTO.ItemDescription = item.ItemDescription;

            return(itemDTO);
        }
Exemple #6
0
        public ItemCategoryDTO GetItemCategoryById(int itemId)
        {
            ItemCategoryDTO itemCategoryDTO = null;
            var             itemCategory    = unitOfWork.ItemRepository.GetById(itemId);

            if (itemCategory != null)
            {
                itemCategoryDTO = ItemConvertor.ConvertToItemCategoryDto(itemCategory);
            }
            return(itemCategoryDTO);
        }
        public ItemCategoryDTO DeleteById(int delete, int id)
        {
            ItemCategory    GetById = _db.ItemCategories.Where(x => x.ItemCategoryId == delete).FirstOrDefault();
            ItemCategoryDTO GetObj  = new ItemCategoryDTO();

            GetObj.ItemCategoryId   = GetById.ItemCategoryId;
            GetObj.ItemCategoryName = GetById.ItemCategoryName;
            GetObj.SignUpId         = GetById.SignUpId;

            return(GetObj);
        }
        public ItemCategoryDTO EditById(int id)
        {
            ItemCategoryDTO Get             = new ItemCategoryDTO();
            ItemCategory    GetItemCategory = _db.ItemCategories.Where(x => x.ItemCategoryId == id).FirstOrDefault();

            Get.SignUpId         = GetItemCategory.SignUpId;
            Get.ItemCategoryId   = GetItemCategory.ItemCategoryId;
            Get.ItemCategoryName = GetItemCategory.ItemCategoryName;

            return(Get);
        }
Exemple #9
0
        public void GetGoodsItemResponseTest()
        {
            var message = new GetGoodsItemResponse();

            Assert.AreEqual(message.Kind, MessageKind.GetGoodsItemResponse);

            var item = new ItemCategoryDTO();

            item.ItemCategoryID = Guid.NewGuid();
            item.Title          = "Title";

            var goodsItem = new GoodsItemDTO();

            goodsItem.GoodsItemID     = Guid.NewGuid();
            goodsItem.Title           = "Title";
            goodsItem.ItemCategoryID  = item.ItemCategoryID;
            goodsItem.BarCode         = "BarCode";
            goodsItem.Description     = "Description";
            goodsItem.DimensionKindID = 1;
            goodsItem.Particular      = "Particular";
            goodsItem.UserCode        = "UserCode";

            message.GoodsItems.Add(goodsItem);
            message.ItemCategories.Add(item);

            var serializer = new ProtocolSerializer(ProtocolVersion.Version10);
            var data       = serializer.Serialize(message);

            Assert.IsNotNull(data);

            var savedMessage = serializer.DeserializeGetGoodsItemResponse(data);

            Assert.IsNotNull(savedMessage);
            Assert.AreEqual(serializer.GetMessageInfoOrNull(data).Kind, MessageKind.GetGoodsItemResponse);
            Assert.AreEqual(savedMessage.GoodsItems.Count, 1);
            Assert.AreEqual(savedMessage.ItemCategories.Count, 1);

            var savedGoodsItems = savedMessage.GoodsItems[0];
            var savedItem       = savedMessage.ItemCategories[0];

            Assert.AreEqual(goodsItem.BarCode, savedGoodsItems.BarCode);
            Assert.AreEqual(goodsItem.Title, savedGoodsItems.Title);
            Assert.AreEqual(goodsItem.Description, savedGoodsItems.Description);
            Assert.AreEqual(goodsItem.DimensionKindID, savedGoodsItems.DimensionKindID);
            Assert.AreEqual(goodsItem.GoodsItemID, savedGoodsItems.GoodsItemID);
            Assert.AreEqual(goodsItem.ItemCategoryID, savedGoodsItems.ItemCategoryID);
            Assert.AreEqual(goodsItem.Particular, savedGoodsItems.Particular);
            Assert.AreEqual(goodsItem.UserCode, savedGoodsItems.UserCode);


            Assert.AreEqual(savedItem.ItemCategoryID, item.ItemCategoryID);
            Assert.AreEqual(savedItem.Title, item.Title);
        }
        public async Task <ActionResult <ItemCategoryDTO> > PostItemCategory(ItemCategoryDTO itemCategoryDTO)
        {
            itemCategoryDTO.AppUserId = User.UserGuidId();
            var bllEntity = _mapper.Map(itemCategoryDTO);

            _bll.ItemCategories.Add(bllEntity);
            await _bll.SaveChangesAsync();

            itemCategoryDTO.Id = bllEntity.Id;

            return(CreatedAtAction("GetItemCategory", new { id = itemCategoryDTO.Id, version = HttpContext.GetRequestedApiVersion()?.ToString() ?? "0" }, itemCategoryDTO));
        }
Exemple #11
0
        public static ItemCategory MapFromDomainEntity(ItemCategoryDTO itemCategory)
        {
            if (itemCategory == null)
            {
                return(null);
            }

            return(new ItemCategory()
            {
                Id = itemCategory.Id,
                Value = itemCategory.Value,
                Position = itemCategory.Position
            });
        }
Exemple #12
0
        public List <ItemCategoryDTO> GetAllCategories()
        {
            List <ItemCategoryDTO> list           = new List <ItemCategoryDTO>();
            List <ItemCategory>    itemCategories = db.ItemCategories.ToList();

            foreach (ItemCategory itemCategory in itemCategories)
            {
                ItemCategoryDTO data = new ItemCategoryDTO();
                data.categoryId = itemCategory.categoryId;
                data.name       = itemCategory.name;
                list.Add(data);
            }

            return(list);
        }
 public ActionResult Edit(ItemCategoryDTO obj, int id)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _itemCategoryData.Edited(obj);
             return(RedirectToAction("Index", "ItemCategory", new { id = id }));
         }
         catch
         {
             throw;
         }
     }
     return(View());
 }
        public void MapFromDomainEntity_ValidEntity_ReturnDTOEntity()
        {
            //Arrange
            var itemCategory = new ItemCategoryDTO()
            {
                Id       = Guid.NewGuid(),
                Value    = "Consultancy Fees",
                Position = 0
            };
            var response = ItemCategory.MapFromDomainEntity(itemCategory);

            Assert.IsNotNull(response);
            Assert.AreEqual(itemCategory.Id, response.Id);
            Assert.AreEqual(itemCategory.Value, response.Value);
            Assert.AreEqual(itemCategory.Position, response.Position);
        }
 public ActionResult AdminCategoryCreate(ItemCategoryDTO obj, int id)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _itemCategoryData.Created(obj);
             return(RedirectToAction("AdminCategoryList", "Admin", new { id = id }));
         }
         catch
         {
             throw;
         }
     }
     return(View());
 }
        public async Task <IActionResult> PutItemCategory(Guid id, ItemCategoryDTO itemCategoryDTO)
        {
            if (id != itemCategoryDTO.Id)
            {
                return(BadRequest(new MessageDTO("Id and itemCategoryEditDTO.id do not match")));
            }

            if (!await _bll.ItemCategories.ExistsAsync(itemCategoryDTO.Id, User.UserGuidId()))
            {
                return(NotFound(new MessageDTO($"Item category with this id {id} not found")));
            }

            itemCategoryDTO.AppUserId = User.UserGuidId();
            await _bll.ItemCategories.UpdateAsync(_mapper.Map(itemCategoryDTO));

            await _bll.SaveChangesAsync();

            return(NoContent());
        }