Beispiel #1
0
        public ProductDto ProductSave([FromBody] ProductDto dto)
        {
            Product product = _mgr.ProductDto2Product(dto);

            _mgr.ProductDto2Resources(dto, product);
            _mgr.ProductDto2Catalogs(dto, product);
            _db.SaveChanges();

            return(_mgr.GetProductDto().FirstOrDefault(e => e.ProductId == product.ProductId));
        }
        public ResponseBase <TBL_SLI_CURRENCY> Insert(TBL_SLI_CURRENCY currency)
        {
            CurrencyValidator validator;

            try
            {
                validator = new CurrencyValidator();
                _results  = validator.Validate(currency);
                if (_results.IsValid)
                {
                    currency.BIT_ACTIVE = true;
                    currency.VCH_NAME   = currency.VCH_NAME.ToUpper();
                    currency.VCH_SYMBOL = currency.VCH_SYMBOL.ToUpper();
                    var currencyFound = _context.TBL_SLI_CURRENCY.Where(x => x.VCH_NAME.Contains(currency.VCH_NAME)).FirstOrDefault();
                    _response = new UtilityResponse <TBL_SLI_CURRENCY>().SetResponseBaseForUniqueValidation();
                    if (currencyFound == null)
                    {
                        _context.TBL_SLI_CURRENCY.Add(currency);
                        _context.SaveChanges();
                        _response = new UtilityResponse <TBL_SLI_CURRENCY>().SetResponseBaseForObj(currency);
                    }
                }
                else
                {
                    _response = new UtilityResponse <TBL_SLI_CURRENCY>().SetResponseBaseFunctionalErrors(_results);
                }
                return(_response);
            }
            catch (Exception ex)
            {
                _response = new UtilityResponse <TBL_SLI_CURRENCY>().SetResponseBaseForException(ex);
                return(_response);
            }
            finally
            {
                _response = null;
                _results  = null;
                validator = null;
                _context.Database.Connection.Close();
            }
        }
        public ResponseBase <TBL_SLI_CONTINENT> Insert(TBL_SLI_CONTINENT continent)
        {
            ContinentValidator validator;

            try
            {
                validator = new ContinentValidator();
                _results  = validator.Validate(continent);
                if (_results.IsValid)
                {
                    continent.BIT_STATE = true;
                    continent.VCH_NAME  = continent.VCH_NAME.ToUpper();
                    var continentFound = _context.TBL_SLI_CONTINENT.Where(x => x.VCH_NAME.Contains(continent.VCH_NAME)).FirstOrDefault();
                    _response = new UtilityResponse <TBL_SLI_CONTINENT>().SetResponseBaseForUniqueValidation();
                    if (continentFound == null)
                    {
                        _context.TBL_SLI_CONTINENT.Add(continent);
                        _context.SaveChanges();
                        _response = new UtilityResponse <TBL_SLI_CONTINENT>().SetResponseBaseForObj(continent);
                    }
                }
                else
                {
                    _response = new UtilityResponse <TBL_SLI_CONTINENT>().SetResponseBaseFunctionalErrors(_results);
                }
                return(_response);
            }
            catch (Exception ex)
            {
                _response = new UtilityResponse <TBL_SLI_CONTINENT>().SetResponseBaseForException(ex);
                return(_response);
            }
            finally
            {
                _response = null;
                _results  = null;
                validator = null;
                _context.Database.Connection.Close();
            }
        }
Beispiel #4
0
        public IActionResult Index(string message)
        {
            if ((message?.Trim() ?? "") == "")
            {
                ViewBag.info = "Enter a message.";
            }
            else
            {
                Message msg = new Message {
                    MessageText = message
                };
                dbc.Messages.Add(msg);
                dbc.SaveChanges();

                logger.LogInformation("New message {MessageId} created", msg.MessageId);

                ViewBag.info = $"Message '{message}' saved.";
            }

            ViewBag.messages = dbc.Messages.OrderBy(x => x.DateCreated).ToList();

            return(View());
        }