public long Insert(BoatPhotos photo) { using (var sqlConnection = new SqlConnection(Constant.DatabaseConnection)) { sqlConnection.Open(); var _photo = new BoatPhotos() { GUID = Guid.NewGuid().ToString(), RECORD_STATUS = 1, INSERT_DATE = DateTime.Now, INSERT_USER = photo.INSERT_USER, UPDATE_DATE = DateTime.Now, UPDATE_USER = photo.UPDATE_USER, BOAT_ID = photo.BOAT_ID, PHOTO = photo.PHOTO }; var boatGuid = sqlConnection.Insert <BoatPhotos>(_photo); sqlConnection.Close(); return(boatGuid); } }
public BoatPhotos Delete(BoatPhotos photo) { BoatPhotos _photo = null; using (var sqlConnection = new SqlConnection(Constant.DatabaseConnection)) { sqlConnection.Open(); _photo = sqlConnection.Get <BoatPhotos>(photo.BOAT_ID); _photo.RECORD_STATUS = 0; _photo.UPDATE_DATE = DateTime.Now; _photo.UPDATE_USER = photo.UPDATE_USER; sqlConnection.Update <BoatPhotos>(_photo); var result = sqlConnection.Get <BoatPhotos>(photo.BOAT_ID); } return(_photo); }
public override void DoOperation() { try { //Validate Reques Header / Constants this.baseResponseMessage = ValidateInput(); if (!this.baseResponseMessage.header.IsSuccess) { throw new Exception(this.baseResponseMessage.header.ResponseMessage); } //Operation switch (this.request.Header.OperationTypes) { case (int)OperationType.OperationTypes.ADD: #region ADD long checkGuid = 0; this.photos = new BoatPhotos { INSERT_USER = this.request.INSERT_USER, UPDATE_USER = this.request.UPDATE_USER, BOAT_ID = this.request.BOAT_ID, PHOTO = this.request.PHOTO }; //Add Data to Database checkGuid = BoatPhotos.Insert(this.photos); this.response = new ResponseBoatPhoto { PHOTO_ID = checkGuid, PHOTO = this.request.PHOTO, BOAT_ID = this.request.BOAT_ID, header = new ResponseHeader { IsSuccess = checkGuid == 0 ? false : true, ResponseCode = checkGuid == 0 ? CommonDefinitions.INTERNAL_SYSTEM_UNKNOWN_ERROR : CommonDefinitions.SUCCESS, ResponseMessage = checkGuid == 0 ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE } }; #endregion break; case (int)OperationType.OperationTypes.UPDATE: #region UPDATE this.photos = new BoatPhotos { UPDATE_USER = this.request.UPDATE_USER, BOAT_ID = this.request.BOAT_ID, PHOTO = this.request.PHOTO }; BoatPhotos.Update(this.photos); this.response = new ResponseBoatPhoto { PHOTO = this.request.PHOTO, BOAT_ID = this.request.BOAT_ID, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; #endregion break; case (int)OperationType.OperationTypes.GET: #region GET listResponseBoatPhoto = new List <ResponseBoatPhoto>(); listresponse = BoatPhotos.SelectByBoatId(this.request.BOAT_ID); foreach (var item in listresponse) { this.response = new ResponseBoatPhoto { BOAT_ID = item.BOAT_ID, PHOTO = item.PHOTO, PHOTO_ID = item.PHOTO_ID, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; listResponseBoatPhoto.Add(this.response); } #endregion break; case (int)OperationType.OperationTypes.DELETE: #region DELETE this.photos = new BoatPhotos { INSERT_USER = this.request.INSERT_USER, UPDATE_USER = this.request.UPDATE_USER, BOAT_ID = this.request.BOAT_ID, PHOTO = this.request.PHOTO }; BoatPhotos.Delete(this.photos); this.response = new ResponseBoatPhoto { BOAT_ID = 0, PHOTO = "", PHOTO_ID = 0, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; #endregion break; default: break; } } catch (Exception ex) { string operationError = "HATA:[" + "BOAT_ID:" + this.request.BOAT_ID + ",ResponseCode:" + this.baseResponseMessage.header.ResponseCode + ", ResponseMessage:" + ex.Message + "]"; log.InfoFormat(operationError, ex); throw new Exception(ex.Message, ex.InnerException); } }