Exemplo n.º 1
0
        public ServiceResult <StoreInvoicing> UpdatestoreInvoicing(StoreInvoicing storeInvoicing)
        {
            var errors = new List <string>();

            if (_context.StoreInvoicings.Any(x => x.Id == storeInvoicing.Id))
            {
                storeInvoicing.IsDelete = true;
                storeInvoicing.StoreInvoicingUpdateDate = DateTime.Now;
                // errors.Add("Mobile is duplicate");
            }

            if (errors.Any())
            {
                return(ServiceResult <StoreInvoicing> .Failed(errors));
            }
            _context.Add(storeInvoicing);
            // _context.Entry(storeInvoicing).State = EntityState.Modified;
            var result = _context.SaveChanges();

            if (result > 0)
            {
                return(ServiceResult <StoreInvoicing> .Succeed(storeInvoicing));
            }
            return(ServiceResult <StoreInvoicing> .Failed(new List <string> {
                "Data not inserted"
            }));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Naam,Formaat")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Exemplo n.º 3
0
        public IActionResult Register(RegisterEmployeeInputModel model)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Error", "Home"));
            }
            var employee = this.mapper.Map <Employee>(model);

            context.Add(employee);
            context.SaveChanges();
            return(this.RedirectToAction("All", "Employees"));
        }
Exemplo n.º 4
0
        public IActionResult Create(CreateOrderInputModel model)
        {
            if (!ModelState.IsValid)
            {
                return(this.RedirectToAction("Error", "Home"));
            }

            model.DateTime = DateTime.UtcNow;
            //total price and quantity... i guess will be skipped
            model.Type = OrderType.ForHere;//for here will be default

            var orderToAdd = this.mapper.Map <Order>(model);

            context.Add(orderToAdd);
            context.SaveChanges();

            return(this.RedirectToAction("All", "Orders"));
        }