public (int Id, string Error) AddPhoto(PhotoRequest photo)
 {
     try
     {
         _context.Photos.Add(new Photo {
             DateCreated = photo.Date, ImageSource = photo.Image, UserId = photo.UserId
         });
         _context.SaveChanges();
         return(_context.Photos.ToList().Last().Id, null);
     }
     catch (Exception e)
     {
         return(-1, e.Message);
     }
 }
Beispiel #2
0
        public (string Error, int id) AddUser(UserRequest user)
        {
            try
            {
                _context.Users.Add(new User {
                    UserLogin = user.UserLogin, UserPassword = user.UserPassword
                });
                _context.SaveChanges();

                return(null, _context.Users.ToList().Last().Id);
            }
            catch (Exception e)
            {
                return(e.Message, -1);
            }
        }
Beispiel #3
0
        public void Seed(PhotoDBContext context)
        {
            Photo pic1 = new Photo()
            {
                Name        = "Italia",
                Colour      = " Grey",
                Price       = 55,
                DateCreated = DateTime.Parse("2018-11-29"),
                Type        = "Portrait",
            };

            context.Photo.Add(pic1);
            context.SaveChanges();
        }
Beispiel #4
0
 public static void Main(string[] args)
 {
     using (var ctx = new PhotoDBContext())
     {
         var location = new Location()
         {
             Adress = "gidoon 2//7", LocationID = "123456"
         };
         var session = new Session()
         {
             Location = location, SessionID = "ParkHaYarkon"
         };
         ctx.Locations.Add(location);
         ctx.Sessions.Add(session);
         ctx.SaveChanges();
     }
     BuildWebHost(args).Run();
 }