예제 #1
0
        public bool AddText([FromBody] TextModel _textModel)
        {
            bool success      = false;
            int  _newDomainId = _textModel.DomainId;

            try
            {
                CommonServices _commonServices = new CommonServices();
                if (_textModel.DomainId == 0)
                {
                    _newDomainId = _commonServices.AddDomainIDs(_textModel.NewDomainToAdd.ToString());
                }



                string[] lines = _textModel.Text1.Split(new[] { "\r\n" }, StringSplitOptions.None);
                for (int i = 0; i < lines.Count(); i++)
                {
                    Text model = new Text();
                    model.DomainId       = _newDomainId;
                    model.DatasetId      = _textModel.DatasetId;
                    model.AddedOn        = _textModel.AddedOn;
                    model.AdditionalInfo = _textModel.AdditionalInfo;
                    model.DataId         = _textModel.DataId;
                    model.LangId         = _textModel.LangId;
                    model.SourceId       = _textModel.SourceId;
                    model.Text1          = lines[i];

                    _textContext.Add(model);

                    success = true;
                }
                _textContext.SaveChanges();
            }
            catch (Exception ex)
            {
                success = false;
            }
            return(success);
        }