public async Task <TranStatus> update_n_addProducts(int Aid, Update_ActivityModel model) { using (activityRepository = new ActivityRepository()) { return(await activityRepository.update_n_addProducts(Aid, model)); } }
public async Task <TranStatus> update_n_addProducts(int Aid, Update_ActivityModel model) { using (var connection = new SqlConnection(ConnectionString)) { await connection.OpenAsync(); TranStatus transaction = new TranStatus(); DynamicParameters parameter = new DynamicParameters(); parameter.Add("@Activity_Id", Aid); //parameter.Add("@Title", model.Title); //parameter.Add("@Description", model.Description); //parameter.Add("@SalesID", model.SalesID); //parameter.Add("@ClientID", model.ClientID); //parameter.Add("@Contact", model.Contact); //parameter.Add("@AppointmentDate", model.AppointmentDate); parameter.Add("@Modifiedby", model.Modifiedby); //Data Table Type -- to insert multiple products DataTable dataTable = model.ProductList.ToDataTable(); parameter.Add("@ProductDetails", dataTable.AsTableValuedParameter("dbo.ProductList")); parameter.Add("@Message", dbType: DbType.String, direction: ParameterDirection.Output, size: 500); parameter.Add("@Code", dbType: DbType.Int32, direction: ParameterDirection.Output); await connection.QueryAsync("update_n_addProducts", parameter, commandType : CommandType.StoredProcedure); transaction.returnMessage = parameter.Get <string>("@Message"); transaction.code = parameter.Get <int>("@Code"); return(transaction); } }
public async Task <IActionResult> update_n_addProducts(int Aid, [FromBody] Update_ActivityModel model) { Dictionary <String, Object> dctData = new Dictionary <string, object>(); HttpStatusCode statusCode = HttpStatusCode.OK; TranStatus transaction = new TranStatus(); try { transaction = await iactivity.update_n_addProducts(Aid, model); } catch (Exception ex) { transaction = CommonHelper.TransactionErrorHandler(ex); statusCode = HttpStatusCode.BadRequest; } dctData.Add("Status", transaction); return(this.StatusCode(Convert.ToInt32(statusCode), dctData)); }