Example #1
0
        public int Update(int Id, TransactionItemVM transactionItemVM)
        {
            var update = myContext.TransactionItems.Find(Id);

            update.Item        = myContext.Items.Where(i => i.Id == transactionItemVM.Item).FirstOrDefault();
            update.Transaction = myContext.Transactions.Where(t => t.Id == transactionItemVM.Transaction).FirstOrDefault();
            update.Update(transactionItemVM);
            return(myContext.SaveChanges());
            //throw new NotImplementedException();
        }
        public IActionResult Put(TransactionItemVM transactionItemVM)
        {
            var data = _transactionItemService.Update(transactionItemVM);

            if (data > 0)
            {
                return(Ok(data));
            }
            return(BadRequest("Failed"));
        }
Example #3
0
        public IActionResult Post(TransactionItemVM transactionItemVM)
        {
            var push = _transactionItemService.Create(transactionItemVM);

            if (push > 0)
            {
                return(Ok("Successfully Added!"));
            }
            return(BadRequest("Added Row Failed!"));
        }
Example #4
0
        public IActionResult Put(int id, TransactionItemVM transactionItemVM)
        {
            var put = _transactionItemService.Update(id, transactionItemVM);

            if (put > 0)
            {
                return(Ok("Update Sucessed!"));
            }
            return(BadRequest("Update Role Failed!"));
        }
        public IActionResult Post(TransactionItemVM transactionItemVM)
        {
            var data = _transactionItemService.Create(transactionItemVM);

            if (data > 0)
            {
                return(Ok(data));
            }
            return(BadRequest("Failed"));
            //var status = Ok(data);
        }
 public int Update(TransactionItemVM transactionItemVM)
 {
     if (string.IsNullOrWhiteSpace(transactionItemVM.ItemId.ToString()))
     {
         return(status);
     }
     else
     {
         return(_transactionItemRepository.Update(transactionItemVM));
     }
 }
 public int Create(TransactionItemVM transactionItemVM)
 {
     using (var conn = new SqlConnection(_connectionString.Value))
     {
         DynamicParameters parameters = new DynamicParameters();
         parameters.Add("@paramItemId", transactionItemVM.itemId);
         parameters.Add("@paramQuantity", transactionItemVM.Quantity);
         var result = conn.Execute("SP_InsertDataTI", parameters, commandType: CommandType.StoredProcedure);
         return(result);
     }
 }
        public JsonResult Insert(TransactionItemVM transactionItemVM)
        {
            var myContent   = JsonConvert.SerializeObject(transactionItemVM);
            var buffer      = System.Text.Encoding.UTF8.GetBytes(myContent);
            var byteContent = new ByteArrayContent(buffer);

            byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var result = Client.PostAsync("transactionItems", byteContent).Result;

            return(Json(result));
        }
 //belum selesai
 public int Update(int Id, TransactionItemVM transactionItemVM)
 {
     using (var conn = new SqlConnection(_connectionString.Value))
     {
         DynamicParameters parameters = new DynamicParameters();
         parameters.Add("@paramId", Id);
         parameters.Add("@paramName", transactionItemVM.Quantity);
         var result = conn.Execute("SP_UpdateDataItem", parameters, commandType: CommandType.StoredProcedure);
         return(result);
     }
 }
 public int Update(TransactionItemVM transactionItemVM)
 {
     parameters.Add("@Quantity", transactionItemVM.Quantity);
     parameters.Add("@TransItem", transactionItemVM.TransactionId);
     parameters.Add("@Item", transactionItemVM.ItemId);
     using (var connection = new SqlConnection(connectionString.Value))
     {
         var data = connection.Execute("SP_UpdateTransItem",
                                       parameters, commandType: CommandType.StoredProcedure);
         return(data);
     }
 }
Example #11
0
        // GET: Items/Edit/5
        public JsonResult Update(TransactionItemVM itemVM)
        {
            var myContent   = JsonConvert.SerializeObject(itemVM);
            var buffer      = System.Text.Encoding.UTF8.GetBytes(myContent);
            var byteContent = new ByteArrayContent(buffer);

            byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            client.DefaultRequestHeaders.Add("Authorization", HttpContext.Session.GetString("Token"));
            var result = client.PutAsync("TransactionItems/" + itemVM.Id, byteContent).Result;

            return(Json(result));
        }
Example #12
0
        public int Create(TransactionItemVM transactionItemVM)
        {
            var push        = new TransactionItem(transactionItemVM);
            var transaction = myContext.Transactions.Find(transactionItemVM.Transaction);

            push.Transaction = transaction;
            var item = myContext.Items.Find(transactionItemVM.Item);

            push.Item = item;
            myContext.TransactionItems.Add(push);
            return(myContext.SaveChanges());
            //throw new NotImplementedException();
        }
        public async Task <TransactionItemVM> Paging(string keyword, int pageNumber, int pageSize)
        {
            using (var conn = new SqlConnection(_connectionString.Value))
            {
                DynamicParameters parameters = new DynamicParameters();
                parameters.Add("@pageSize", pageSize);
                parameters.Add("@pageNumber", pageNumber);
                parameters.Add("@paramKeyword", keyword);
                parameters.Add("@length", dbType: DbType.Int32, direction: ParameterDirection.Output);
                parameters.Add("@filterLength", dbType: DbType.Int32, direction: ParameterDirection.Output);
                var result = new TransactionItemVM();
                result.data = await conn.QueryAsync <TransactionItemVM>("SP_FilterDataTransactionItem", parameters, commandType : CommandType.StoredProcedure);

                int filterlength = parameters.Get <int>("@filterLength");
                result.filterLength = filterlength;
                int length = parameters.Get <int>("@length");
                result.length = length;
                return(result);
            }
        }
Example #14
0
 public int Create(TransactionItemVM transactionItemVM)
 {
     return(_transactionRepository.Create(transactionItemVM));
 }
Example #15
0
 public int Update(int Id, TransactionItemVM transactionItemVM)
 {
     return(_transactionItemRepository.Update(Id, transactionItemVM));
     //throw new NotImplementedException();
 }
Example #16
0
 public int Create(TransactionItemVM transactionItemVM)
 {
     return(_transactionItemRepository.Create(transactionItemVM));
     //throw new NotImplementedException();
 }
 public IActionResult Create(TransactionItemVM transactionItemVM)
 {
     return(Ok(_transactionItemServices.Create(transactionItemVM)));
 }
Example #18
0
 public int Update(int id, TransactionItemVM transactionItemVM)
 {
     return(_transactionRepository.Update(id, transactionItemVM));
 }
Example #19
0
 public void Update(TransactionItemVM transactionItemVM)
 {
     this.Quantity   = transactionItemVM.Quantity;
     this.UpdateDate = DateTimeOffset.Now;
 }
Example #20
0
 public TransactionItem(TransactionItemVM transactionItemVM)
 {
     this.Quantity   = transactionItemVM.Quantity;
     this.CreateDate = DateTimeOffset.Now;
     this.IsDelete   = false;
 }
 public TransactionItem(TransactionItemVM transactionItemVM)
 {
     this.Quantity = transactionItemVM.Quantity;
 }