public HttpResponseMessage Post([FromBody] NewPassRecoveryModel value) { try { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, value)); } var db = passRecoverySvc.Save(MapToDB(value)); return(Request.CreateResponse(HttpStatusCode.OK, db)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
protected PassRecovery MapToDB(NewPassRecoveryModel item) { var passRecovery = new PassRecovery(); var user = userSvc.LoadAll(x => x.Email == item.Email).FirstOrDefault(); if (user != null) { passRecovery = new PassRecovery() { Id = Guid.NewGuid(), UserId = user.Id, ValidTo = DateTime.Now.AddDays(1) }; } ; return(passRecovery); }