public int AddOperation(OperationAddModel operation) { try { int result = -1; Operation newOperation = new Operation() { Summ = operation.Summ, CategoryId = operation.CategoryId, IsProfit = operation.IsProfit, WayOfPayId = operation.WayOfPayId }; repository.Add(newOperation); result = 1; return(result); } catch (Exception ex) { throw ex; } }
public int Register(UserRegistrationModel user) { try { int result = -1; User newUser; newUser = new User() { Login = user.Login, Password = user.Password, Name = user.Name, Surname = user.Surname, Email = user.Email, CardBalance = user.CardBalance, CashBalance = user.CashBalance }; repository.Add(newUser); result = 1; _context.Categories.Add(new Category() { Name = "Clothing", Summ = 0, UserId = newUser.ID, ImageSource = @"Gallery\clothing.png" }); _context.Categories.Add(new Category() { Name = "Dining", Summ = 0, UserId = newUser.ID, ImageSource = @"Gallery\Dining.png" }); _context.Categories.Add(new Category() { Name = "Education", Summ = 0, ImageSource = @"Gallery\education.png", UserId = newUser.ID }); _context.Categories.Add(new Category() { Name = "Freetime", Summ = 0, ImageSource = @"Gallery\freetime.png", UserId = newUser.ID }); _context.Categories.Add(new Category() { Name = "Health", Summ = 0, ImageSource = @"Gallery\health.png", UserId = newUser.ID }); _context.Categories.Add(new Category() { Name = "Home", Summ = 0, UserId = newUser.ID, ImageSource = @"Gallery\home.png" }); _context.Categories.Add(new Category() { Name = "Transport", Summ = 0, ImageSource = @"Gallery\transport.png", UserId = newUser.ID }); _context.SaveChanges(); return(result); } catch (Exception ex) { throw ex; } }