Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using UIKit;
- namespace iOSApp
- {
- public partial class signUpViewController : UIViewController
- {
- partial void SignUpButton_TouchUpInside(UIButton sender)
- {
- throw new NotImplementedException();
- }
- public signUpViewController(IntPtr handle) : base(handle)
- {
- }
- public override void ViewDidLoad()
- {
- base.ViewDidLoad();
- // Perform any additional setup after loading the view, typically from a nib.
- }
- public override void DidReceiveMemoryWarning()
- {
- base.DidReceiveMemoryWarning();
- // Release any cached data, images, etc that aren't in use.
- }
- }
- }
- using DBCore;
- using DBCore.Tables;
- using System;
- using System.Collections.Generic;
- using System.Data.Entity.Infrastructure;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DBBusinessLogic
- {
- public class userOperations
- {
- public userOperations()
- {
- }
- public int createNewUser(string usr, string pass, string emailAddress, string fName, string lName)
- {
- try
- {
- using (studyGroupContext db = new studyGroupContext())
- {
- var c = db.users.Where(b => b.email == emailAddress).ToList(); //checking if the emailAddress exists
- if (c.Count > 0)
- return 1;
- c = db.users.Where(b => b.userName == usr).ToList();
- //checking if the emailAddress exists
- if (c.Count > 0)
- return 2;
- users entry = new users { userName = usr, password = pass, email = emailAddress, firstName = fName, lastName = lName };
- db.users.Add(entry);
- int i=db.SaveChanges();
- if(i==1)
- return 0;
- }
- }
- catch (DbUpdateException)
- {
- throw;
- }
- return 3;
- }
- public int logIn(string usr, string pass)
- {
- try {
- using (var db = new studyGroupContext())
- {
- var c = db.users.Where(b => b.userName == usr).ToList();//get the list that contains this user
- if (c.Count == 0)
- return 1;//no user exception
- if (c[0].password == pass)
- return 0;//return 0 is for success
- else
- return 2;//wrong password exception
- }
- }
- catch(Exception)
- {
- return 3;//unknown exception
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement