Exemple #1
0
        public ResultDto ChangeStatus(int DistrictId, int userId)
        {
            ResultDto resultDto  = new ResultDto();
            string    obectName  = "District";
            string    statusCode = string.Empty;

            try
            {
                ObjectParameter prmDistrictID   = new ObjectParameter("DistrictID", DistrictId);
                ObjectParameter prmDistrictCode = new ObjectParameter("DistrictCode", string.Empty);
                ObjectParameter prmStatusCode   = new ObjectParameter("StatusCode", string.Empty);

                int effectedCount = _dbContext.uspDistrictChangeStatus(prmDistrictID, prmDistrictCode, prmStatusCode, userId);

                resultDto.ObjectId   = (int)prmDistrictID.Value;
                resultDto.ObjectCode = (string)prmDistrictCode.Value;
                statusCode           = (string)prmStatusCode.Value;

                if (resultDto.ObjectId > 0)
                {
                    resultDto.Message = string.Format("{0} : {1} details {2} successfully", obectName, resultDto.ObjectCode, statusCode == Constants.StatusCodes.Active ? "activated" : "inactivated");
                }
                else
                {
                    resultDto.Message = string.Format("Error occured while {0} {1} details", statusCode == Constants.StatusCodes.Active ? "activated" : "inactivated", obectName);
                }
            }
            catch (Exception)
            {
                resultDto.Message  = string.Format("Service layer error occured while {0} {1} details", statusCode == Constants.StatusCodes.Active ? "activated" : "inactivated", obectName);
                resultDto.ObjectId = -98;
            }
            return(resultDto);
        }