public IActionResult Login([FromForm] LoginModel model) { ResponseModel responseModel = new ResponseModel(); if (model != null) { var singleUser = _context.Users.Where(x => x.Email == model.Email && x.Password == model.Password).AsNoTracking(); if (singleUser.Any()) { // Update UserData var user = singleUser.FirstOrDefault(); user.AuthorizeTokenKey = _channelPartnerService.GenerateAuthorizeTokenKey(); user.FCMId = model.FCMId; _context.Users.Update(user); _context.SaveChanges(); responseModel.Message = ChannelPartnerConstantString.Login_Success.ToString(); responseModel.Data = _channelPartnerModelFactory.PrepareUserDetail(user); return(StatusCode((int)HttpStatusCode.OK, responseModel)); } else { responseModel.Message = "Email & Password not matching for specified data"; return(StatusCode((int)HttpStatusCode.Unauthorized, responseModel)); } } return(Ok()); }
public async Task <IActionResult> Register([FromForm] CommonRegistrationModel model) { ResponseModel responseModel = new ResponseModel(); if (ModelState.IsValid) { ChannelPartner ChannelPartnerData = JsonConvert.DeserializeObject <ChannelPartner>(model.Data.ToString()); if (ChannelPartnerData != null) { var singleUser = _channelPartnerManagementContext.Users.Where(x => x.Email == ChannelPartnerData.Email).AsNoTracking(); if (!singleUser.Any()) { List <IFormFile> files = new List <IFormFile>(); files.Add(model.File); (int channelPartnerId, string uniqueNo) = _channelPartnerService.SaveChannelPartner(ChannelPartnerData, files); string UserName = ChannelPartnerData.FirstName + uniqueNo; var user = _channelPartnerService.SaveUserData(channelPartnerId, Module.ChannelPartner, UserName, ChannelPartnerData.Email); await Task.Run(() => _channelPartnerService.SendVerificationLinkEmail(ChannelPartnerData.Email, user.Password, Module.ChannelPartner.ToString())); responseModel.Message = ChannelPartnerConstantString.Register_ChannelPartner_Success.ToString(); responseModel.Data = _channelPartnerModelFactory.PrepareUserDetail(user); return(StatusCode((int)HttpStatusCode.OK, responseModel)); } else { responseModel.Message = ChannelPartnerConstantString.Validation_EmailExist.ToString(); return(StatusCode((int)HttpStatusCode.Conflict, responseModel)); } } return(StatusCode((int)HttpStatusCode.BadRequest)); } else { return(StatusCode((int)HttpStatusCode.BadRequest, ModelState)); } }