public UpdateCreationResponse UpdateCreation(UpdateCreationRequest request)
        {
            var response = new UpdateCreationResponse {
                ResponseStatus = ResponseStatus.Success
            };

            var creationsProvider = new CreationsProvider();

            try
            {
                if (request.ActionType == ActionType.Update)
                {
                    response.IsSucessful = creationsProvider.UpdateCreation(request);
                }
                else
                {
                    response.ResponseStatus      = ResponseStatus.Failure;
                    response.ResponseDescription = "Not update action";
                }
            }
            catch (Exception ex)
            {
                response.ResponseStatus      = ResponseStatus.Failure;
                response.ResponseDescription = ex.Message;
            }
            return(response);
        }
        public UpdateCreationRequest GetUpdateCreationRequest(Creation creation)
        {
            var request = new UpdateCreationRequest()
            {
                Creation   = creation,
                ActionType = Requests.ActionType.Update
            };

            return(request);
        }
示例#3
0
        internal bool UpdateCreation(UpdateCreationRequest request)
        {
            var conn           = GetConnection(ConnectionNames.CSPSqlDatabase);
            var commandWrapper = GetStoredProcCommand("dbo.UpdateCreation", conn);

            AddInParameter(commandWrapper, "@CreationId", DbType.Int16, request.Creation.CreationId);

            var services = "";

            foreach (var service in request.Creation.Services)
            {
                services += service.ServiceId + ",";
            }

            AddInParameter(commandWrapper, "@JobType", DbType.String, services.Substring(0, services.Length - 1));
            AddInParameter(commandWrapper, "@Mail", DbType.String, request.Creation.Mail);
            AddInParameter(commandWrapper, "@Name", DbType.String, request.Creation.Name);
            AddInParameter(commandWrapper, "@PhoneNumber", DbType.String, request.Creation.PhoneNumber);
            AddInParameter(commandWrapper, "@ClientType", DbType.Int16, request.Creation.ClientType);
            AddInParameter(commandWrapper, "@UserId", DbType.Int16, request.Creation.UserId);
            AddInParameter(commandWrapper, "@Note", DbType.String, request.Creation.Note);
            AddInParameter(commandWrapper, "@PaymentMethod", DbType.Int16, request.Creation.PaymentMethod);
            AddInParameter(commandWrapper, "@PIB", DbType.String, request.Creation.PIB);
            AddInParameter(commandWrapper, "@Amount", DbType.Int32, request.Creation.Amount);
            AddInParameter(commandWrapper, "@CompanySubType", DbType.String, request.Creation.CompanySubType);

            AddInParameter(commandWrapper, "@ERROR", DbType.String, 1000);
            AddInParameter(commandWrapper, "@ERROR_CODE", DbType.String, 4);

            try
            {
                conn.Open();
                int results = commandWrapper.ExecuteNonQuery();

                var isProcedureSucced = Convert.ToBoolean(results);
                MakeDboLog(request.ToString(), isProcedureSucced.ToString(), "dbo.UpdateCreation");

                var errorObject     = GetParameterValue(commandWrapper, "@ERROR");
                var errorCodeObject = GetParameterValue(commandWrapper, "@ERROR_CODE");

                return(Convert.ToBoolean(results));
            }
            finally
            {
                commandWrapper.Dispose();
                conn.Close();
            }
        }