示例#1
0
        public Backer AddBacker(AddBackerOptions options)
        {
            if (options == null)
            {
                return(null);
            }

            if (options.Donate <= 0.0M)
            {
                return(null);
            }

            //Email and phone must me submited for new Backer
            if (string.IsNullOrEmpty(options.Email) || string.IsNullOrEmpty(options.Phone))
            {
                return(null);
            }

            var Backer = new Backer()
            {
                Donate = options.Donate,
                Email  = options.Email,
                Phone  = options.Phone
            };

            if (!string.IsNullOrEmpty(options.Firstname))
            {
                Backer.Firstname = options.Firstname;
            }

            if (!string.IsNullOrEmpty(options.Lastname))
            {
                Backer.Lastname = options.Lastname;
            }

            context.Add(Backer);
            try {
                context.SaveChanges();
                Console.WriteLine("ok new");
            } catch (Exception ex) {
                //Console.WriteLine("no new");
                return(null);
            }
            return(Backer);
        }
示例#2
0
        public void AddBacker_Success()
        {
            var options = new AddBackerOptions()
            {
                Firstname = "54654444654",
                Lastname  = "5465444454",
                Email     = "ge54546s444dfsdfs1df",
                Phone     = "5454664544455546154",
                Donate    = 150
            };

            //bcsv_.AddBacker(new AddBackerOptions()
            //{
            //    Email = "fdsfsd",
            //    Firstname = "dfsfsd",
            //    Lastname = "dsfdsfsdf",
            //    Phone = "sdfdsfsdfsdfsd"
            //    ,Donate=5
            //});

            var result = bcsv_.AddBacker(options);

            Assert.NotNull(result);
        }