Пример #1
0
 public IActionResult Post([FromBody] ItemTypeBO i)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     return(Ok(facade.ItemTypeService.Create(i)));
 }
Пример #2
0
 public ItemTypeBO Create(ItemTypeBO it)
 {
     using (var uow = facade.UnitOfWork)
     {
         var newItemType = uow.ItemTypeRepo.Create(conv.Convert(it));
         uow.Complete();
         return(conv.Convert(newItemType));
     }
 }
        public void ConvertBOToEntId()
        {
            var item = new ItemTypeBO()
            {
                Id = 1
            };
            ItemType bo = converter.Convert(item);

            Assert.AreEqual(bo.Id, 1);
        }
Пример #4
0
        private void PopulateItemType()
        {
            this.ddlItemType.Items.Clear();
            this.ddlItemType.Items.Add(new ListItem("Select Item Type..", "0"));

            List <ItemTypeBO> lstItemTypes = new ItemTypeBO().SearchObjects();

            foreach (ItemTypeBO objType in lstItemTypes)
            {
                this.ddlItemType.Items.Add(new ListItem(objType.Name, objType.ID.ToString()));
            }
        }
Пример #5
0
        public ItemTypeBO Update(ItemTypeBO it)
        {
            using (var uow = facade.UnitOfWork)
            {
                var itemTypeFromDb = uow.ItemTypeRepo.Get(it.Id);
                if (itemTypeFromDb == null)
                {
                    throw new InvalidOperationException("ItemType not found");
                }
                itemTypeFromDb.Name = it.Name;

                uow.Complete();
                return(conv.Convert(itemTypeFromDb));
            }
        }
Пример #6
0
        public IActionResult Put(int id, [FromBody] ItemTypeBO i)
        {
            if (id != i.Id)
            {
                return(BadRequest("Path ID does not match ItemType ID in json object"));
            }

            try
            {
                return(Ok(facade.ItemTypeService.Update(i)));
            }
            catch (InvalidOperationException e)
            {
                return(StatusCode(404, e.Message));
            }
        }
Пример #7
0
        public List <ItemTypeBO> GetItemTypes()
        {
            try
            {
                string            sql      = "dbo.fn_getItemTypes";
                List <ItemTypeBO> itemlist = new List <ItemTypeBO>();

                conn = new NpgsqlConnection(connString);
                conn.Open();

                using (var cmd = new NpgsqlCommand(sql, conn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    var reader = cmd.ExecuteReader();
                    do
                    {
                        while (reader.Read())
                        {
                            var BO = new ItemTypeBO();
                            BO.itemtypekey = Guid.Parse(reader["itemtypekey"].ToString());
                            BO.itemtypeid  = Utils.CustomParse <short>(reader["itemtypeid"]);
                            BO.description = Utils.CustomParse <string>(reader["description"]);
                            //BO.createdate = Utils.CustomParse<DateTime>(reader["createdate"]);
                            // BO.createuserkey = Utils.CustomParse<Guid>(reader["createuserkey"]);

                            itemlist.Add(BO);
                        }
                    }while (reader.NextResult());
                    reader.Close();
                }

                return(itemlist);
            }
            catch (Exception msg)
            {
                throw msg;
            }
            finally
            {
                conn.Close();
            }
        }