Exemplo n.º 1
0
        public TableResponse <TableReturn> DeleteRequest(string requestNo)
        {
            var requestTransaction = new RequestHeaderDto
            {
                RequestNo      = requestNo,
                RequestDetails = new List <RequestDetailDto>()
            };

            return(SaveRequest(requestTransaction, TransactionTypes.Delete.ToString()));
        }
Exemplo n.º 2
0
        public ActionResult UpdateRequest(RequestHeaderDto request)
        {
            var response = _requestRepository.UpdateRequest(request);

            if (response.OutList != null && response.OutList.Count() > 0)
            {
                return(new JsonErrorResult(response, HttpStatusCode.PartialContent));
            }
            else if (response.Ok)
            {
                return(Ok(response));
            }
            else
            {
                return(new JsonErrorResult(new { Message = response.Message }, HttpStatusCode.InternalServerError));
            }
        }
Exemplo n.º 3
0
        private TableResponse <TableReturn> SaveRequest(RequestHeaderDto requestTransaction, string transcationType)
        {
            #region Sql Parameter loading
            List <SqlParameter> parms = new List <SqlParameter>
            {
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[0].ToString(), Value = requestTransaction.RequestNo.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[1].ToString(), Value = requestTransaction.CustomerCode.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[2].ToString(), Value = requestTransaction.DeliveryDate.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[3].ToString(), Value = requestTransaction.OrderReceivedBy.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[4].ToString(), Value = requestTransaction.Remarks.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[5].ToString(), Value = requestTransaction.AuthorizedOfficerId.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[6].ToString(), Value = requestTransaction.CartonCount.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[7].ToString(), Value = requestTransaction.RequestType.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[8].ToString(), Value = requestTransaction.UserId.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[9].ToString(), Value = requestTransaction.Status.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[10].ToString(), Value = requestTransaction.ServiceTypeId.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[11].ToString(), Value = requestTransaction.WorkOrderType.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[12].ToString(), Value = requestTransaction.ContactPersonName.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[13].ToString(), Value = requestTransaction.DeliveryLocation.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[14].ToString(), Value = requestTransaction.DeliveryRouteId.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[15].ToString(), Value = transcationType.AsDbValue()
                },

                new SqlParameter
                {
                    ParameterName = RequestStoredProcedure.StoredProcedureParameters[16].ToString(),
                    TypeName      = RequestStoredProcedure.StoredProcedureTypeNames[0].ToString(),
                    SqlDbType     = SqlDbType.Structured,
                    Value         = requestTransaction.RequestDetails.ToList().ToDataTable()
                },
            };
            #endregion
            var resultTable   = _tcContext.Set <TableReturn>().FromSqlRaw(RequestStoredProcedure.Sql, parms.ToArray()).ToList();
            var tableResponse = new TableResponse <TableReturn>
            {
                Message = resultTable.Where(x => x.Reason == "OK" || x.Reason == "NOK").FirstOrDefault().OutValue,
                Ok      = resultTable.Where(x => x.Reason == "OK").FirstOrDefault() != null ? true : false,
                OutList = resultTable.Where(x => x.Reason != "OK" && x.Reason != "NOK").ToList()
            };
            return(tableResponse);
        }
Exemplo n.º 4
0
 public TableResponse <TableReturn> UpdateRequest(RequestHeaderDto requestUpdate)
 {
     return(SaveRequest(requestUpdate, TransactionTypes.Update.ToString()));
 }
Exemplo n.º 5
0
 public TableResponse <TableReturn> AddRequest(RequestHeaderDto requestInsert)
 {
     return(SaveRequest(requestInsert, TransactionTypes.Insert.ToString()));
 }
Exemplo n.º 6
0
 public ActionResult DeleteRequest(RequestHeaderDto request)
 {
     return(Ok(_requestRepository.DeleteRequest(request.RequestNo)));
 }