예제 #1
0
        public int AddInventoryGroup(InventoryGroupPM group, string credentialsId)
        {
            group.AccountNumberIdRef = _accountRepository.GetAccountForUser(credentialsId).AccountNumberId;

            _context.InventoryGroups.Add(group);
            _context.SaveChanges();
            return(group.InventoryGroupId);
        }
예제 #2
0
        public string GetInventoryGroup(int id)
        {
            InventoryGroupPM x = _posRepository.GetInventoryGroup(id, GetCurrentUserId());

            return(JsonConvert.ToString(new InventoryGroup()
            {
                Description = x.Description,
                InventoryGroupId = x.InventoryGroupId,
                Name = x.Name,
            }.ToJsonString()));
        }
예제 #3
0
        public void DeleteInventoryGroup(int id, string credentialsId)
        {
            InventoryGroupPM g = GetInventoryGroup(id, credentialsId);

            if (g == null)
            {
                throw new ValidationException("no group found");
            }

            _context.InventoryGroups.Remove(g);
            _context.SaveChanges();
        }
예제 #4
0
        public void UpdateInventoryGroup(InventoryGroupPM group, string credentialsId)
        {
            InventoryGroupPM groupOld = GetInventoryGroup(group.InventoryGroupId, credentialsId);

            if (groupOld == null)
            {
                throw new ValidationException("no group found");
            }

            //InventoryGroupPM group = new InventoryGroupPM() { Name = name, Description = description };
            groupOld.Update(group);
            _context.SaveChanges();
        }
예제 #5
0
        public int AddInventoryGroup(string json)
        {
            InventoryGroup ig = InventoryGroup.FromJsonString(json);

            if (!Validate.NameValidation(ig.Name))
            {
                throw new ValidationException("Invalid name");
            }

            if (!Validate.NameValidation(ig.Description))
            {
                throw new ValidationException("Invalid description");
            }

            InventoryGroupPM pm = new InventoryGroupPM()
            {
                Name        = ig.Name,
                Description = ig.Description,
            };

            return(_posRepository.AddInventoryGroup(pm, GetCurrentUserId()));
        }