Exemplo n.º 1
0
 public IActionResult Update(SalesPerson model)
 {
     if (model != null)
     {
         model.Status = "1";
         if (model.Id == 0)
         {
             model.CreatedDate = DateTime.Now;
             _dbContext.SalesPerson.Add(model);
         }
         else
         {
             var res = _dbContext.SalesPerson.Where(x => x.Id == model.Id).FirstOrDefault();
             if (res != null)
             {
                 res.ModifiedDate = model.ModifiedDate;
                 res.Name         = model.Name;
                 res.DepartmentId = model.DepartmentId;
                 res.CreatedDate  = DateTime.Now;
                 res.Status       = model.Status;
                 res.ModifiedBy   = model.ModifiedBy;
                 _dbContext.SalesPerson.Update(res);
             }
         }
         _dbContext.SaveChanges();
     }
     //redirect to edit
     //return RedirectToAction("Edit", new { id = model.Id });
     return(RedirectToAction("Index"));
 }
Exemplo n.º 2
0
 public IActionResult Update(Vendor model)
 {
     if (model != null)
     {
         model.Status = "1";
         if (model.Id == 0)
         {
             model.CreatedDate = DateTime.Now;
             _dbContext.Vendor.Add(model);
         }
         else
         {
             model.CreatedDate = DateTime.Now;
             var res = _dbContext.Vendor.Where(x => x.Id == model.Id).FirstOrDefault();
             if (res != null)
             {
                 res.CreatedDate   = DateTime.Now;
                 res.Name          = model.Name;
                 res.Address       = model.Address;
                 res.EmailId       = model.EmailId;
                 res.EmailId2      = model.EmailId2;
                 res.ContactNo     = model.ContactNo;
                 res.ContactPerson = model.ContactPerson;
                 res.ModifiedDate  = model.ModifiedDate;
                 res.ModifiedBy    = model.ModifiedBy;
                 _dbContext.Vendor.Update(res);
             }
         }
         _dbContext.SaveChanges();
     }
     // return RedirectToAction("Edit", new { id = model.Id });
     return(RedirectToAction("Index"));
 }
 public IActionResult Update(Department model)
 {
     if (model != null)
     {
         model.Status = "1";
         if (model.Id == 0)
         {
             model.CreatedDate = DateTime.Now;
             _dbContext.Department.Add(model);
         }
         else
         {
             var res = _dbContext.Department.Where(x => x.Id == model.Id).FirstOrDefault();
             if (res != null)
             {
                 res.ModifiedDate = model.ModifiedDate;
                 res.Name         = model.Name;
                 res.CreatedDate  = DateTime.Now;
                 res.Status       = model.Status;
                 res.ModifiedBy   = model.ModifiedBy;
                 _dbContext.Department.Update(res);
             }
         }
         _dbContext.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
        public void Register(RegisterInputModel input)
        {
            // Push a command through the stack

            var match = new Match {
                Id = input.Id, Team1 = input.Team1, Team2 = input.Team2
            };

            _commandDbContext.Matches.Add(match);
            _commandDbContext.SaveChanges();
        }
Exemplo n.º 5
0
        public IActionResult Delete(int id)
        {
            var result = _dbContext.Users.Where(w => w.Id.Equals(id)).FirstOrDefault();

            result.RecStatus = (result.RecStatus == 'A' || result.RecStatus == null) ? 'D' : 'A';

            _dbContext.Users.Update(result);
            _dbContext.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
 public void Register(RegisterInputModel input)
 {
     // Push a command through the stack
     using (var db = new CommandDbContext())
     {
         var match = new Match {
             Id = input.Id, Team1 = input.Team1, Team2 = input.Team2
         };
         db.Matches.Add(match);
         db.SaveChanges();
     }
 }
 public void AgregarProducto(ProductoInputModel productoModel)
 {
     using (var db = new CommandDbContext())
     {
         db.Productos.Add(new Command.Producto
         {
             Nombre          = productoModel.Nombre,
             CategoriaNombre = productoModel.Categoria,
             TipoNombre      = productoModel.Tipo
         });
         db.SaveChanges();
     }
 }
Exemplo n.º 8
0
 public IActionResult Update(ItemGroup model)
 {
     if (model != null)
     {
         model.Status = "1";
         if (model.ParentItemGroupId == "0")
         {
             model.ItemGroupNLevelString = model.ItemGroupName;
         }
         else
         {
             var ItemNLevelName = _dbContext.ItemGroup.Where(x => x.Id.ToString() == model.ParentItemGroupId).Select(s => s.ItemGroupNLevelString).FirstOrDefault();
             model.ItemGroupNLevelString = ItemNLevelName + ">>" + model.ItemGroupName;
         }
         if (model.Id == 0)
         {
             model.CreatedDate = DateTime.Now;
             _dbContext.ItemGroup.Add(model);
         }
         else
         {
             var res = _dbContext.ItemGroup.Where(x => x.Id == model.Id).FirstOrDefault();
             if (res != null)
             {
                 res.ModifiedDate          = model.ModifiedDate;
                 res.ItemGroupName         = model.ItemGroupName;
                 res.ItemGroupNLevelString = model.ItemGroupNLevelString;
                 res.CreatedDate           = DateTime.Now;
                 res.Status     = model.Status;
                 res.ModifiedBy = model.ModifiedBy;
                 _dbContext.ItemGroup.Update(res);
             }
         }
         _dbContext.SaveChanges();
     }
     //redirect to edit
     //return RedirectToAction("Edit", new { id = model.Id });
     return(RedirectToAction("Index"));
 }
Exemplo n.º 9
0
        private void SeedRooms()
        {
            if (_context.Rooms.Any())
            {
                return;
            }

            var rooms = new Room[]
            {
                new Room("Family", RoomType.Default()),
                new Room("Friends", RoomType.Other()),
                new Room("Work", RoomType.Other()),
            };

            _context.Rooms.AddRange(rooms);
            _context.SaveChanges();
        }
Exemplo n.º 10
0
        public DatabaseFixture()
        {
            _connection = new SqliteConnection("datasource=:memory:");
            _connection.Open();

            _options = new DbContextOptionsBuilder <CommandDbContext>()
                       .UseSqlite(_connection)
                       .Options;
            TestContext = new CommandDbContext(_options);
            TestContext.Database.EnsureCreated();
            TestContext.Articles.AddRange(ArticleList.GetDefaultList());
            TestContext.SaveChanges();

            _readOnlyOptions = new DbContextOptionsBuilder <QueryDbContext>()
                               .UseSqlite(_connection)
                               .Options;
            TestReadOnlyContext = new QueryDbContext(_readOnlyOptions);
            TestReadOnlyContext.Database.EnsureCreated();
        }
        public IActionResult add([FromBody] Bill model)
        {
            var No = _dbContext.Bills.Where(w => w.No.Equals(model.No)).FirstOrDefault();

            if (ModelState.IsValid && model != null && No == null)
            {
                model.Date        = DateTime.Now;
                model.CreatedDate = DateTime.Now;
                model.Recstatus   = 'A';
                model.CreatedBy   = CustomerContext.UserId.ToString();
                model.SalesPerson = CustomerContext.UserId;
                _dbContext.Bills.Add(model);
                _dbContext.SaveChanges();
                TempData["success"] = $"Purchase Invoice No:{model.No} created successfully";
                return(Json(model.Id));
            }
            return(BadRequest(ModelState));
        }