public ResponseStatus Login(string phoneNumber, int loginId) { ResponseStatus response = new ResponseStatus(); using (mom_androidEntities context = new mom_androidEntities()) { userloginmaster u = new userloginmaster(); u.PhoneNumber = phoneNumber; u.LoginID = loginId; u.OTP = SendOTP(u.PhoneNumber); var data = context.userloginmasters.Where(x => x.LoginID == u.LoginID && x.PhoneNumber == u.PhoneNumber).FirstOrDefault(); if (data != null) { context.userloginmasters.Where(p => p.LoginID == u.LoginID && p.PhoneNumber == u.PhoneNumber).ToList().ForEach(x => x.OTP = u.OTP); } var result = context.SaveChanges(); if (result > 0) { response.isSuccess = true; response.serverResponseTime = System.DateTime.Now; } else { response.isSuccess = false; response.serverResponseTime = System.DateTime.Now; } } return(response); }
public UserModel Login(string phonenumber) { //ResponseStatus response = new ResponseStatus(); UserModel user = new UserModel(); using (mom_androidEntities context = new mom_androidEntities()) { userloginmaster u = new userloginmaster(); var data = context.userloginmasters.Where(x => x.PhoneNumber == phonenumber).FirstOrDefault(); if (data == null) { u.PhoneNumber = phonenumber; u.OTP = SendOTP(u.PhoneNumber); context.userloginmasters.Add(u); } else { var userdata = context.userloginmasters.Where(x => x.PhoneNumber == phonenumber); foreach (var item in userdata) { item.OTP = SendOTP(phonenumber); } } var result = context.SaveChanges(); if (result > 0) { var userdata = context.userloginmasters.Where(x => x.PhoneNumber == phonenumber).FirstOrDefault(); if (userdata != null) { user.LoginID = Convert.ToInt32(userdata.LoginID); user.Name = userdata.Name; user.PhoneNumber = userdata.PhoneNumber; user.OTP = (int)userdata.OTP; user.RoleId = Convert.ToInt32(userdata.RoleId); user.EmailID = userdata.EmailID; //user.DataBaseId = Convert.ToInt32(userdata.DataBaseId); user.StoreId = Convert.ToInt32(userdata.StoreId); //user.ProfilePictureUrl = "http://103.233.79.234/Data/EverGreen_Android/EverGreenProfilePicture/" + userdata.LoginID + ".jpeg"; } } } return(user); }