Exemple #1
0
        public IHttpActionResult Validate([FromBody] DuplexModel model)
        {
            try
            {
                var duplex = new Duplex(model.DuplexId);
                Mapper.Map(model, duplex);
                if (_duplexesService.IsDuplexExists(duplex))
                {
                    model.SetError("Duplex", "A duplex with this configuration already exists.");
                }

                return(Ok(model));
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemple #2
0
        public IHttpActionResult CreateMultiple([FromBody] ICollection <DuplexModel> models)
        {
            var duplexes = new List <Duplex>();

            foreach (var duplexModel in models)
            {
                var duplex = new Duplex();
                Mapper.Map(duplexModel, duplex);
                if (!_duplexesService.IsDuplexExists(duplex))
                {
                    _duplexesService.CreateDuplex(duplex);
                    duplexModel.Id = duplex.Id;
                }
                else
                {
                    duplexModel.SetError("Duplex", "A duplex with this configuration already exists.");
                }
            }

            return(Ok(models));
        }