Ejemplo n.º 1
0
        private ResultDto InsertUpdate(DistrictDto district)
        {
            ResultDto resultDto = new ResultDto();
            string    obectName = "district";

            try
            {
                ObjectParameter prmDistrictID     = new ObjectParameter("DistrictID", district.DistrictID);
                ObjectParameter paramDistrictCode = new ObjectParameter("DistrictCode", string.Empty);
                int             effectedCount     = _dbContext.uspDistrictInsertUpdate(prmDistrictID, district.District, district.TEDistrictName, district.StateID, district.UserId, paramDistrictCode);

                resultDto.ObjectId   = (int)prmDistrictID.Value;
                resultDto.ObjectCode = (string)paramDistrictCode.Value;
                resultDto.ObjectCode = string.IsNullOrEmpty((string)paramDistrictCode.Value) ? district.DistrictCode : (string)paramDistrictCode.Value;


                if (resultDto.ObjectId > 0)
                {
                    resultDto.Message = string.Format("{0} details saved successfully with code : {1}", obectName, resultDto.ObjectCode);
                }
                else if (resultDto.ObjectId == -1)
                {
                    resultDto.Message = string.Format("Error occured while generating {0} code", obectName);
                }
                else
                {
                    resultDto.Message = string.Format("Error occured while saving {0} details", obectName);
                }
            }
            catch (Exception)
            {
                resultDto.Message  = string.Format("Service layer error occured while saving the {0} details", obectName);
                resultDto.ObjectId = -98;
            }
            return(resultDto);
        }