public IHttpActionResult Put(AssessorPreferredLocation assessorPreferredLocation, int assessorPreferredLocationId = 0) { OperationStatus operationStatus = new OperationStatus() { ServiceMethod = "PUT", ServiceName = "UpdateAssessorPreferredLocation", RequestProcessed = false, RequestSuccessful = false }; if (assessorPreferredLocation != null) { if (assessorPreferredLocationId > 0) { //Comment : Here set value of assessorPreferredLocationId into DTO object and then call Update method assessorPreferredLocation.Id = assessorPreferredLocationId; operationStatus = GetAssessorPreferredLocationDbService().UpdatePreferredLocation(assessorPreferredLocation); } else { operationStatus.Messages.Add(new Message() { DTOName = "AssessorPreferredLocation", DTOProperty = "", MessageType = MessageType.SystemError, Text = "Please use POST method to create object." }); } } return(Ok(operationStatus)); }
private Int64 SubmitAssessorPreferredLocations(AssessorPreferredLocation data) { var parameterList = new List <System.Data.IDbDataParameter> { new SqlParameter() { ParameterName = "@Id", Value = data.Id, SqlDbType = SqlDbType.BigInt }, new SqlParameter() { ParameterName = "@AssessorId", Value = data.AssessorId, SqlDbType = SqlDbType.BigInt }, new SqlParameter() { ParameterName = "@CityId", Value = data.CityId, SqlDbType = SqlDbType.Int }, //5S Params new SqlParameter() { ParameterName = "@CreatedBy", Value = data.CreatedBy, SqlDbType = SqlDbType.Int }, new SqlParameter() { ParameterName = "@ModifiedBy", Value = data.ModifiedBy, SqlDbType = SqlDbType.Int }, new SqlParameter() { ParameterName = "@IsActive", Value = data.IsActive, SqlDbType = SqlDbType.Bit }, new SqlParameter() { ParameterName = "AssessorId", SqlDbType = SqlDbType.BigInt, Direction = ParameterDirection.ReturnValue } }; //Comment : Here get DbConnector object var rowEffeted = GetDbConnector().ExecuteNonQuery("MaintainAssessorPreferredLocations", QueryCommandType.StoredProcedure, parameterList); //if successfully executed if (rowEffeted > 0) { Int64 assessorId = Convert.ToInt32(parameterList[parameterList.Count() - 1].Value); return(assessorId); } else { //LoggingService.Instance.Fatal(string.Format("Unable to add user :{0}{1}", Environment.NewLine, object)); } return(0); }
OperationStatus IAssessorPreferredLocationDbService.AddPreferredLocation(AssessorPreferredLocation data) { OperationStatus operationStatus = new OperationStatus() { RequestProcessed = false, RequestSuccessful = false }; #region Comment : Here Add/Create details try { #region Supply data object for DB insertion //Comment : Here record id which is being effected at db level Int64 effectedRecordId = SubmitAssessorPreferredLocations(data); //if successfully executed if (effectedRecordId > 0) { //Comment : Here if data has been "successfully submitted" then capture those details operationStatus.RequestProcessed = true; operationStatus.RequestSuccessful = true; operationStatus.ServiceName = "AddAssessorPreferredLocation"; operationStatus.ServiceMethod = "POST"; operationStatus.AffectedIds.Add(new AffectedId() { DTOName = "AssessorPreferredLocation", DTOProperty = "AssessorId", IdValue = effectedRecordId.ToString(), OperationType = OperationType.POST }); } else { //LoggingService.Instance.Fatal(string.Format("Unable to add user :{0}{1}", Environment.NewLine, object)); } #endregion } catch (Exception ex) { operationStatus.RequestProcessed = true; operationStatus.RequestSuccessful = false; operationStatus.Messages.Add(new Message() { DTOName = "AssessorPreferredLocation", DTOProperty = "", MessageType = MessageType.SystemError, Text = ex.Message }); } #endregion return(operationStatus); }
public IHttpActionResult Post(AssessorPreferredLocation assessor) { OperationStatus operationStatus = new OperationStatus() { ServiceMethod = "POST", ServiceName = "AddAssessorPreferredLocation", RequestProcessed = false, RequestSuccessful = false }; if (assessor != null) { if (assessor.Id == 0) { operationStatus = GetAssessorPreferredLocationDbService().AddPreferredLocation(assessor); } else { operationStatus.Messages.Add(new Message() { DTOName = "AssessorPreferredLocation", DTOProperty = "", MessageType = MessageType.SystemError, Text = "Please use PUT method to update state of object." }); } } return(Ok(operationStatus)); }