Пример #1
0
        public async Task <IActionResult> Create([Bind("ProductId,Name,ProductNumber,MakeFlag,FinishedGoodsFlag,Color,SafetyStockLevel,ReorderPoint,StandardCost,ListPrice,Size,SizeUnitMeasureCode,WeightUnitMeasureCode,Weight,DaysToManufacture,ProductLine,Class,Style,ProductSubcategoryId,ProductModelId,SellStartDate,SellEndDate,DiscontinuedDate,Rowguid,ModifiedDate")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductModelId"]        = new SelectList(_context.ProductModels, "ProductModelId", "Name", product.ProductModelId);
            ViewData["ProductSubcategoryId"]  = new SelectList(_context.ProductSubcategories, "ProductSubcategoryId", "Name", product.ProductSubcategoryId);
            ViewData["SizeUnitMeasureCode"]   = new SelectList(_context.UnitMeasures, "UnitMeasureCode", "UnitMeasureCode", product.SizeUnitMeasureCode);
            ViewData["WeightUnitMeasureCode"] = new SelectList(_context.UnitMeasures, "UnitMeasureCode", "UnitMeasureCode", product.WeightUnitMeasureCode);
            return(View(product));
        }
Пример #2
0
        public async Task <string> CreateHolidayAsync(HolidayDto holiday)
        {
            try
            {
                var holidayModel = this.mapper.Map <Holiday>(holiday);
                await dbContext.Holidays.AddAsync(holidayModel).ConfigureAwait(false);

                await dbContext.SaveChangesAsync().ConfigureAwait(false);

                return(holiday.Id.ToString());
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #3
0
        public async Task <string> CreateEvent(EventDto e)
        {
            try
            {
                var eventModel = this.mapper.Map <Event>(e);
                await dbContext.Events.AddAsync(eventModel).ConfigureAwait(false);

                await dbContext.SaveChangesAsync().ConfigureAwait(false);

                return(e.EventId.ToString());
            }
            catch (Exception ex)
            {
                ex.ToString();
                throw;
            }
        }