Advertisement
Guest User

Untitled

a guest
Apr 6th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. using System;
  2.  
  3. using UIKit;
  4.  
  5. namespace iOSApp
  6. {
  7. public partial class signUpViewController : UIViewController
  8. {
  9. partial void SignUpButton_TouchUpInside(UIButton sender)
  10. {
  11. throw new NotImplementedException();
  12. }
  13.  
  14. public signUpViewController(IntPtr handle) : base(handle)
  15. {
  16. }
  17.  
  18. public override void ViewDidLoad()
  19. {
  20. base.ViewDidLoad();
  21. // Perform any additional setup after loading the view, typically from a nib.
  22. }
  23.  
  24. public override void DidReceiveMemoryWarning()
  25. {
  26. base.DidReceiveMemoryWarning();
  27. // Release any cached data, images, etc that aren't in use.
  28. }
  29. }
  30. }
  31.  
  32. using DBCore;
  33. using DBCore.Tables;
  34. using System;
  35. using System.Collections.Generic;
  36. using System.Data.Entity.Infrastructure;
  37. using System.Linq;
  38. using System.Text;
  39. using System.Threading.Tasks;
  40.  
  41. namespace DBBusinessLogic
  42. {
  43. public class userOperations
  44. {
  45. public userOperations()
  46. {
  47.  
  48. }
  49.  
  50. public int createNewUser(string usr, string pass, string emailAddress, string fName, string lName)
  51. {
  52. try
  53. {
  54. using (studyGroupContext db = new studyGroupContext())
  55. {
  56. var c = db.users.Where(b => b.email == emailAddress).ToList(); //checking if the emailAddress exists
  57. if (c.Count > 0)
  58. return 1;
  59. c = db.users.Where(b => b.userName == usr).ToList();
  60. //checking if the emailAddress exists
  61. if (c.Count > 0)
  62. return 2;
  63. users entry = new users { userName = usr, password = pass, email = emailAddress, firstName = fName, lastName = lName };
  64. db.users.Add(entry);
  65. int i=db.SaveChanges();
  66. if(i==1)
  67. return 0;
  68.  
  69. }
  70. }
  71. catch (DbUpdateException)
  72. {
  73. throw;
  74. }
  75. return 3;
  76. }
  77.  
  78. public int logIn(string usr, string pass)
  79. {
  80. try {
  81. using (var db = new studyGroupContext())
  82. {
  83. var c = db.users.Where(b => b.userName == usr).ToList();//get the list that contains this user
  84. if (c.Count == 0)
  85. return 1;//no user exception
  86. if (c[0].password == pass)
  87. return 0;//return 0 is for success
  88. else
  89. return 2;//wrong password exception
  90. }
  91. }
  92. catch(Exception)
  93. {
  94. return 3;//unknown exception
  95. }
  96.  
  97. }
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement