Пример #1
0
        //-> uploadimages
        public async Task <ItemViewDTO> UploadImages(ItemUploadImageDTO itemUploadImage)
        {
            tblItem item = db.tblItems.FirstOrDefault(r => r.item_Deleted == null && r.id == itemUploadImage.id);

            if (item == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, "This record does not exsists or has been deleted");
            }
            using (var transaction = db.Database.BeginTransaction())
            {
                try
                {
                    List <sm_doc> documents = await DocumentHelper.SaveUploadImage(db, ConstantHelper.document_ItemTableID, itemUploadImage.id, itemUploadImage.base64s);

                    transaction.Commit();

                    return(await SelectByID(item.id));
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw new Exception(ex.Message);
                }
            }
        }
Пример #2
0
 public async Task <IHttpActionResult> UploadImages(int id, [FromBody] ItemUploadImageDTO item)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         return(Ok(await repository.UploadImages(item)));
     }
     catch (HttpException ex)
     {
         return(BadRequest(ex.Message));
     }
 }