public static string GetRegionName(int regionID) { try { Region region = regionService.SelectByRegionId(regionID); ResponseRegion response = new ResponseRegion { REGION_ID = region.REGION_ID, REGION_NAME = region.REGION_NAME, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; return(response.REGION_NAME); } catch (Exception ex) { throw new Exception(CommonDefinitions.REQUEST_ID_NOT_FOUND); } }
public override void DoOperation() { //Validate Reques Header / Constants this.baseResponseMessage = ValidateInput(); if (!this.baseResponseMessage.header.IsSuccess) { throw new Exception(this.baseResponseMessage.header.ResponseMessage); } try { switch (this.request.Header.OperationTypes) { case (int)OperationType.OperationTypes.ADD: #region ADD long checkGuid = 0; this.region = new Region { INSERT_USER = this.request.INSERT_USER, UPDATE_USER = this.request.UPDATE_USER, REGION_NAME = this.request.REGION_NAME }; checkGuid = regionService.Insert(this.region); this.response = new ResponseRegion { INSERT_USER = this.request.INSERT_USER, UPDATE_USER = this.request.UPDATE_USER, REGION_ID = checkGuid, REGION_NAME = this.request.REGION_NAME, 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.GET: #region GET if (this.request.REGION_ID != 0) { this.region = regionService.SelectByRegionId(this.request.REGION_ID); response = new ResponseRegion { REGION_ID = this.region.REGION_ID, REGION_NAME = this.region.REGION_NAME, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; } else { this.listRegion = regionService.SelectAllRegion(); if (this.listRegion != null && this.listRegion.Count() > 0) { listResponseRegion = new List <ResponseRegion>(); foreach (var item in this.listRegion) { this.response = new ResponseRegion { REGION_ID = item.REGION_ID, REGION_NAME = item.REGION_NAME, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; listResponseRegion.Add(this.response); } } } #endregion break; case (int)OperationType.OperationTypes.UPDATE: #region UPDATE this.region = new Region { INSERT_USER = this.request.INSERT_USER, UPDATE_USER = this.request.UPDATE_USER, REGION_NAME = this.request.REGION_NAME }; regionService.Update(this.region); response = new ResponseRegion { REGION_ID = this.region.REGION_ID, REGION_NAME = this.region.REGION_NAME, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; #endregion break; case (int)OperationType.OperationTypes.DELETE: #region DELETE this.region = new Region { INSERT_USER = this.request.INSERT_USER, UPDATE_USER = this.request.UPDATE_USER, REGION_NAME = this.request.REGION_NAME }; regionService.Delete(this.region); response = new ResponseRegion { REGION_ID = 0, REGION_NAME = "", header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; #endregion break; default: break; } } catch (Exception ex) { throw new Exception(ex.Message); } }