Пример #1
0
        public bool UpdateBacker(UpdateBacker options)
        {
            if (options == null)
            {
                return(false);
            }

            var backer = SearchBackerId(options.Id);

            if (!string.IsNullOrWhiteSpace(options.FirstName))
            {
                backer.FirstName = options.FirstName;
            }
            if (!string.IsNullOrWhiteSpace(options.LastName))
            {
                backer.LastName = options.LastName;
            }
            if (!string.IsNullOrWhiteSpace(options.Password))
            {
                backer.Password = options.Password;
            }
            if (options.NewDonate > 0)
            {
                backer.Donate = options.NewDonate;
            }
            try
            {
                context_.SaveChanges();
            } catch (Exception ex) {
                Console.WriteLine("UPDATE FAIL" + ex);
                return(false);
            }

            return(true);
        }
Пример #2
0
        public async Task <bool> UpdateProjectCreator(int id, UpdateCreator options)
        {
            var creator = SearchCreatorById(id);

            if ((id <= 0) ||
                (options == null) ||
                (creator == null) ||
                (options.TotalCost <= 0.0M))
            {
                return(false);
            }
            if (!string.IsNullOrWhiteSpace(options.FirstName))
            {
                creator.FirstName = options.FirstName;
            }
            if (!string.IsNullOrWhiteSpace(options.LastName))
            {
                creator.LastName = options.LastName;
            }
            if (!string.IsNullOrWhiteSpace(options.Password))
            {
                creator.Password = options.Password;
            }
            if (creator == null)
            {
                //elegxo gia ton creator
            }

            var UpdProjectCreator = context_.Set <Creator>().SingleOrDefault(p => p.Id == id);

            if (UpdProjectCreator == null)
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(UpdProjectCreator.FirstName))
            {
                UpdProjectCreator.FirstName = options.FirstName;
            }

            if (!string.IsNullOrEmpty(UpdProjectCreator.LastName))
            {
                UpdProjectCreator.LastName = options.LastName;
            }

            if (!string.IsNullOrEmpty(UpdProjectCreator.Email))
            {
                UpdProjectCreator.Email = options.Email;
            }

            if (UpdProjectCreator.TotalCost > 0)
            {
                UpdProjectCreator.TotalCost = options.TotalCost;
            }
            context_.Update(UpdProjectCreator);
            try {
                context_.SaveChanges();
                Console.WriteLine("Update creator ok");
            } catch (Exception ex) {
                Console.WriteLine("UPDATE CREATOR FAIL" + ex);
                return(false);
            }
            return(true);
        }