コード例 #1
0
 public GuardarResponse Guardar(Producto producto)
 {
     producto.GenPrecio();
     _context.Productos.Add(producto);
     _context.SaveChanges();
     return(new GuardarResponse(producto));
 }
コード例 #2
0
 public GuardarResponseVo Guardar(List <Producto> prds, int venta)
 {
     prds.ForEach(x => _context.Vendidos.Add(new Vendido(x, venta)));
     //_context.Vendidos.Add(vendido);
     _context.SaveChanges();
     return(new GuardarResponseVo(new Vendido(prds[0], venta)));
 }
コード例 #3
0
 public OftenBeneficiary AddBeneficiar(OftenBeneficiary Beneficiary)
 {
     dbContext.OftenBeneficiary.Add(Beneficiary);
     dbContext.SaveChanges();
     dbContext.Entry(Beneficiary).Reference(Beneficiary => Beneficiary.PayeeType).Load();
     return(Beneficiary);
 }
コード例 #4
0
        public IHttpActionResult Delete([FromBody] int id)
        {
            var pp = db.Personas.ToList().Find(x => x.IdPersona == id);

            db.Personas.Remove(pp);
            db.SaveChanges();

            return(Ok());
        }
コード例 #5
0
ファイル: ClientesController.cs プロジェクト: yondryc/Tarea2
        public ActionResult Create([Bind(Include = "Id,Nombre,Apellido,Direccion")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                db.Clientes.Add(cliente);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cliente));
        }
コード例 #6
0
        public ActionResult Create([Bind(Include = "Id,Nombre,CodigoPostal,Edad,Email,TarjetaCredito")] Persona persona)
        {
            if (ModelState.IsValid)
            {
                db.Persona.Add(persona);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(persona));
        }
コード例 #7
0
        public ActionResult Create(Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                db.Clientes.Add(cliente);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cliente));
        }
コード例 #8
0
        public IActionResult Create([FromBody] Employee item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            _context.Employee.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetAll", new { id = item.EmployeeId }, item));
        }
コード例 #9
0
ファイル: PrestamosController.cs プロジェクト: yondryc/Tarea2
        public ActionResult Create([Bind(Include = "Id,Capital,Intereses,Periodo,ClientesId")] Prestamos prestamos)
        {
            if (ModelState.IsValid)
            {
                db.Prestamos.Add(prestamos);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ClientesId = new SelectList(db.Clientes, "Id", "Nombre", prestamos.ClientesId);
            return(View(prestamos));
        }
コード例 #10
0
 public bool AddRemitSetting(BussinessUnitRemitSetting remitSetting)
 {
     try
     {
         dbContext.BussinessUnitRemitSetting.Add(remitSetting);
         dbContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         logger.LogDebug(ex.Message);
     }
     return(false);
 }
コード例 #11
0
 public bool AddPayeeRelation(PayeeRelationType Relation)
 {
     try
     {
         dbContext.PayeeRelationType.Add(Relation);
         dbContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         logger.LogDebug(ex.Message);
     }
     return(false);
 }
コード例 #12
0
 public bool AddCurrency(CurrencyCode currency)
 {
     try
     {
         dbContext.CurrencyCode.Add(currency);
         dbContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         logger.LogDebug(ex.Message);
     }
     return(false);
 }
コード例 #13
0
 public bool AddReceiveBank(ReceiveBank bank)
 {
     try
     {
         dbContext.ReceiveBank.Add(bank);
         dbContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         logger.LogDebug(ex.Message);
     }
     return(false);
 }
        public void UpdateTransactionStatus(long recordId, short transactionStatus, string comment)
        {
            var record = _context.RemitRecord.SingleOrDefault(x => x.Id == recordId);

            _context.Entry(record).Reference(record => record.ToCurrency).Load();
            var exchangeRate = _context.ExchangeRate.SingleOrDefault(x => x.CurrencyName.Equals(record.ToCurrency.CurrencyName));
            var originalTransactionStatus = record.TransactionStatus;

            if (record == null)
            {
                return;
            }
            record.TransactionStatus       = transactionStatus;
            record.TransactionExchangeRate = exchangeRate.Rate;
            RemitAdminReviewLog reviewLog = new RemitAdminReviewLog()
            {
                RemitRecordId         = recordId,
                FromTransactionStatus = originalTransactionStatus,
                ToTransactionStatus   = transactionStatus,
                Note = comment
            };

            record.RemitAdminReviewLog.Add(reviewLog);
            _context.Update(record);
            _context.SaveChanges();
        }
コード例 #15
0
 static void Main(string[] args)
 {
     using (var ctx = new GeneralContext()) {
         SalesRepresentative emp = new SalesRepresentative()
         {
             Name = "Prashant"
         };
         ctx.SalesRepresentatives.Add(emp);
         ctx.SaveChanges();
     }
 }
コード例 #16
0
        public void TestSeed1()
        {
            using (var temp = new GeneralContext())
            {
                var user = new User()
                {
                    Age                     = 28,
                    FirstName               = "Harry",
                    LastName                = "Person",
                    Friends                 = new List <User>(),
                    SentPosts               = new List <Post>(),
                    ReceivedPosts           = new List <Post>(),
                    PrivateMessagesReceived = new List <PrivateMessage>(),
                    PrivateMessagesSent     = new List <PrivateMessage>()
                };

                var user2 = new User()
                {
                    Age       = 28,
                    FirstName = "Steven",
                    LastName  = "Lister",
                    Friends   = new List <User>()
                    {
                        user
                    },
                    SentPosts               = new List <Post>(),
                    ReceivedPosts           = new List <Post>(),
                    PrivateMessagesReceived = new List <PrivateMessage>(),
                    PrivateMessagesSent     = new List <PrivateMessage>()
                };

                var user3 = new User()
                {
                    Age       = 28,
                    FirstName = "Jane",
                    LastName  = "Bottle",
                    Friends   = new List <User>()
                    {
                        user,
                        user2
                    },
                    SentPosts               = new List <Post>(),
                    ReceivedPosts           = new List <Post>(),
                    PrivateMessagesReceived = new List <PrivateMessage>(),
                    PrivateMessagesSent     = new List <PrivateMessage>()
                };

                temp.Users.Add(user);
                temp.Users.Add(user2);
                temp.Users.Add(user3);
                temp.SaveChanges();
            }
        }
コード例 #17
0
        public async Task <IActionResult> AddToPlaylist(int?id)
        {
            if (id != null || id != 0)
            {
                var          user          = from s in _context.Users where s.Name == User.Identity.Name select s.ID;
                int          u_id          = user.FirstOrDefault();
                UserPlaylist userPlaylistC = (from s in _context.UserPlaylist
                                              where s.SongID == id && s.UserID == u_id
                                              select s).SingleOrDefault();
                if (userPlaylistC == null)
                {
                    var song = await _context.Songs.SingleOrDefaultAsync(m => m.ID == id);

                    UserPlaylist userPlaylist = new UserPlaylist {
                        SongID = song.ID, UserID = u_id
                    };
                    _context.UserPlaylist.Add(userPlaylist);
                    _context.SaveChanges();
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
コード例 #18
0
        public ActionResult Guardar(string nombre, string apellido, string correo)
        {
            GeneralContext db      = new GeneralContext();
            Clientes       cliente = new Clientes();

            cliente.nombre   = nombre;
            cliente.apellido = apellido;
            cliente.correo   = correo;
            db.Clientes.Add(cliente);
            db.SaveChanges();

            return(PartialView("Lista", db.Clientes.ToList()));
        }
コード例 #19
0
        public ActionResult Eliminar(int id)
        {
            GeneralContext db      = new GeneralContext();
            var            cliente = db.Clientes.ToList().Find(x => x.idCliente == id);

            if (cliente != null)
            {
                db.Clientes.Remove(cliente);
                db.SaveChanges();
            }


            return(PartialView("Lista", db.Clientes.ToList()));
        }
コード例 #20
0
        void Guardar(string nombre, string apellido, string correo, string telefono)
        {
            Personas persona = new Personas();

            persona.Nombre   = nombre;
            persona.Apellido = apellido;
            persona.Correo   = correo;
            persona.Telefono = telefono;

            db.Personas.Add(persona);
            db.SaveChanges();

            Mostrar();
        }
コード例 #21
0
ファイル: PropertyDAO.cs プロジェクト: viktor-mains/XayahBot
 public void SetValue(Property property)
 {
     using (GeneralContext database = new GeneralContext())
     {
         TProperty dbProperty = database.Properties.FirstOrDefault(x => x.Name.Equals(property.Name));
         if (dbProperty == null)
         {
             dbProperty = new TProperty
             {
                 Name = property.Name
             };
             database.Properties.Add(dbProperty);
         }
         dbProperty.Value = property.Value;
         database.SaveChanges();
     }
 }
コード例 #22
0
        public void TestUserCreateMessage1()
        {
            using (var context = new GeneralContext())
            {
                var user1 = context.Users.FirstOrDefault(x => x.Id == 1);
                var user2 = context.Users.FirstOrDefault(x => x.Id == 2);

                var message = new PrivateMessage()
                {
                    Content  = "Content 1",
                    Sender   = user1,
                    Receiver = user2
                };

                context.PrivateMessages.Add(message);
                context.SaveChanges();
            }
        }
コード例 #23
0
        public async Task <bool> AddNewUserInfo(UserRegisterType loginUser)
        {
            using var transaction = dbContext.Database.BeginTransaction();
            try
            {
                var user = new User();
                await dbContext.User.AddAsync(user);

                dbContext.SaveChanges();
                var userArc = new UserArc()
                {
                    UserId = user.Id
                };
                await dbContext.UserArc.AddAsync(userArc);

                dbContext.SaveChanges();


                var userRegisterType = new UserRegisterType()
                {
                    UserId         = user.Id,
                    AuthPlatformId = loginUser.AuthPlatformId,
                    RegisterType   = loginUser.RegisterType,
                    Email          = loginUser.Email,
                    Name           = loginUser.Name
                };
                await dbContext.UserRegisterType.AddAsync(userRegisterType);

                dbContext.SaveChanges();

                // Commit transaction if all commands succeed, transaction will auto-rollback
                // when disposed if either commands fails
                transaction.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                logger.LogError(ex, null);
                transaction.Rollback();
                return(false);
            }
        }
コード例 #24
0
        public void TestPosts2()
        {
            using (var context = new GeneralContext())
            {
                var user1 = context.Users.FirstOrDefault(x => x.Id == 1);
                var user2 = context.Users.FirstOrDefault(x => x.Id == 2);

                var p = new TextPost()
                {
                    Name     = "Name 1",
                    Receiver = user1,
                    Sender   = user2,
                    Subject  = "Saying Hi 1",
                    Content  = "Content 1"
                };

                context.TextPosts.Add(p);
                context.SaveChanges();
            }
        }
コード例 #25
0
        public void TestPosts1()
        {
            using (var context = new GeneralContext())
            {
                var user1 = context.Users.FirstOrDefault(x => x.Id == 3);
                var user2 = context.Users.FirstOrDefault(x => x.Id == 4);

                var p = new ImagePost()
                {
                    Name     = "Name 1",
                    Receiver = user2,
                    Sender   = user1,
                    Subject  = "Saying Hi",
                    Url      = "www.google.com/image1"
                };

                context.ImagePosts.Add(p);
                context.SaveChanges();
            }
        }
コード例 #26
0
        public RemitRecord CreateRemitRecordByUserArc(UserArc userArc, RemitRecord remitRecord, PayeeTypeEnum payeeTypeEnum)
        {
            remitRecord.UserId    = userArc.UserId;
            remitRecord.ArcName   = userArc.ArcName;
            remitRecord.ArcNo     = userArc.ArcNo;
            remitRecord.PayeeType = (byte)payeeTypeEnum;

            dbContext.RemitRecord.Add(remitRecord);
            dbContext.SaveChanges();
            dbContext.Entry(remitRecord).Reference(record => record.Beneficiary).Query()
            .Include(Beneficiary => Beneficiary.PayeeRelation)
            .Load();
            dbContext.Entry(remitRecord).Reference(record => record.ToCurrency).Load();

            return(remitRecord);
        }
コード例 #27
0
        public LoginController(GeneralContext context, IOptions <AppSetting> appSettings)
        {
            _context = context;
            var admin = _context.Users.Find("admin");

            if (admin == null)
            {
                _context.Users.Add(new User()
                {
                    UserName    = "******",
                    Password    = "******",
                    Email       = "*****@*****.**",
                    Estado      = "AC",
                    FirstName   = "Adminitrador",
                    LastName    = "",
                    MobilePhone = "31800000000"
                }
                                   );
                var registrosGuardados = _context.SaveChanges();
            }
            _userService = new UserService(context);
            _jwtService  = new JwtService(appSettings);
        }
コード例 #28
0
 public void AddLoginLog(UserLoginLog userLogingLog)
 {
     dbContext.UserLoginLog.Add(userLogingLog);
     dbContext.SaveChanges();
 }
コード例 #29
0
 public void AddScanRecord(ArcScanRecord record)
 {
     dbContext.ArcScanRecord.Add(record);
     dbContext.SaveChanges();
 }
コード例 #30
0
 public void Modify(User user)
 {
     _context.Entry(user).State = EntityState.Modified;
     _context.SaveChanges();
 }