public int AddInventoryGroup(InventoryGroupPM group, string credentialsId) { group.AccountNumberIdRef = _accountRepository.GetAccountForUser(credentialsId).AccountNumberId; _context.InventoryGroups.Add(group); _context.SaveChanges(); return(group.InventoryGroupId); }
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())); }
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(); }
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(); }
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())); }