Exemplo n.º 1
0
        public static bool AddLoanRequest(LoanRequest request)
        {
            try
            {
                using (var context = new HackathonContext())
                {
                    context.LoanRequests.Add(request);

                    var user = context.Users.FirstOrDefault(x => x.UserId == request.User.UserId);

                    if (user != null)
                    {
                        user.CreditPoints        += 100;
                        context.Entry(user).State = EntityState.Modified;
                    }

                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception)
            {
                //ignored
            }

            return(false);
        }
        public bool Update(DataAccessInstagram data)
        {
            try
            {
                using (var db = new HackathonContext())
                {
                    var table = db.Set <DataAccessInstagram>();

                    table.Attach(data);
                    db.Entry <DataAccessInstagram>(data).State = System.Data.Entity.EntityState.Modified;

                    db.SaveChanges();

                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }