예제 #1
0
        public CSDMdefsDetails GetCSDMdefsDetails(string xml)
        {
            CSDMdefsDetails     details   = new CSDMdefsDetails();
            string              spName    = MIDDerivationLibrary.Models.Constants.spCheckIsCSDMdefsDetailsExist;
            List <SqlParameter> allParams = new List <SqlParameter>()
            {
                new SqlParameter($"@{MIDDerivationLibrary.Models.Constants.xmlInput}", xml)
            };

            DataSet result = sqlRepository.ExecuteQuery(spName, allParams);

            if (result != null && result.Tables[0].Rows.Count > 0)
            {
                details = result.Tables[0].AsEnumerable().Select(dataRow => new CSDMdefsDetails
                {
                    id       = dataRow.Field <long>("id"),
                    csdmfile = dataRow.Field <string>("CSDMfile"),
                    componentCodeRangeStart = dataRow.Field <decimal?>("componentcoderangestart"),
                    componentCodeRangeEnd   = dataRow.Field <decimal?>("componentcoderangeend"),
                    csdmSize          = dataRow.Field <int?>("CSDMsize"),
                    csdmRelative      = dataRow.Field <bool?>("CSDMrelative"),
                    defaultShaftLabel = dataRow.Field <string>("defaultshaftlabel")
                }).FirstOrDefault();
            }
            return(details);
        }
예제 #2
0
        public ActionResult UpdateCSDMdefsDetails(CSDMdefsDetails model)
        {
            long id = 0;

            try
            {
                string   xmlString = XmlHelper.ConvertObjectToXML(model);
                XElement xElement  = XElement.Parse(xmlString);

                bool isExist = _service.CheckIsCSDMdefsDetailsExist(xmlString);

                if (isExist == true)
                {
                    return(StatusCode(StatusCodes.Status409Conflict, new ApiResponse(404, Constants.recordExist)));
                }
                else
                {
                    id = _service.AddOrUpdateCSDMdefsDetails(xElement.ToString());
                    if (id > 0)
                    {
                        return(Ok(new ApiOkResponse(id, Constants.recordSaved)));
                    }
                    else
                    {
                        return(StatusCode(StatusCodes.Status500InternalServerError, new ApiResponse(500, null)));
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return(Ok(new ApiOkResponse(id)));
        }
예제 #3
0
        public ActionResult GetCSDMdefsDetailsById(long id)
        {
            try
            {
                if (id <= 0)
                {
                    return(BadRequest(new ApiBadRequestResponse()));
                }
                else
                {
                    bool isExist = _service.CheckIsCSDMdefsDetailsExist(id);
                    if (isExist == false)
                    {
                        return(StatusCode(StatusCodes.Status404NotFound, new ApiResponse(404, Constants.recordNotFound)));
                    }

                    CSDMdefsDetails details = _service.GetCSDMdefsDetailsById(id);

                    if (details != null)
                    {
                        return(Ok(new ApiOkResponse(details)));
                    }
                    else
                    {
                        return(StatusCode(StatusCodes.Status500InternalServerError, new ApiResponse(500, null)));
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
                return(StatusCode(StatusCodes.Status500InternalServerError, new ApiResponse(500, null)));
            }
        }
예제 #4
0
        public CSDMdefsDetails GetCSDMdefsDetailsById(long id)
        {
            CSDMdefsDetails details = null;

            details = _csdMdefsRepository.GetCSDMdefsDetailsById(id);
            return(details);
        }
예제 #5
0
        public bool CheckIsCSDMdefsDetailsExist(string xmlContent)
        {
            bool            flag    = false;
            CSDMdefsDetails details = null;

            details = _csdMdefsRepository.GetCSDMdefsDetails(xmlContent);
            if (details != null && details.id > 0)
            {
                flag = true;
            }

            return(flag);
        }
예제 #6
0
        public bool CheckIsCSDMdefsDetailsExist(long id)
        {
            bool            flag    = true;
            CSDMdefsDetails details = null;

            details = _csdMdefsRepository.GetCSDMdefsDetailsById(id);
            if (details != null && details.id == 0)
            {
                flag = false;
            }

            return(flag);
        }