public HttpResponseMessage CreateUser([FromBody] User value) { try { using (var context = new ToPDFDBContext()) { var user = new User(); user.AddressLine1 = value.AddressLine1; user.AddressLine2 = value.AddressLine2; user.City = value.City; user.CompanyName = value.CompanyName; user.CompanyWebsite = value.CompanyWebsite; user.Country = value.Country; user.Email = value.Email; user.FirstName = value.FirstName; user.LastName = value.LastName; user.Password = value.Password; user.Phone = value.Phone; user.PostCode = value.PostCode; user.State = value.State; user.Avatar = value.Avatar; user.CreatedDate = DateTime.Now; context.Users.Add(user); context.SaveChanges(); return(SendHttpResponse("Success", HttpStatusCode.OK)); } } catch (Exception ex) { return(SendHttpResponse(ex.Message, HttpStatusCode.InternalServerError)); } }
public HttpResponseMessage CreateTemplate([FromBody] Models.PdfTemplate template) { try { using (var context = new ToPDFDBContext()) { using (var dbContextTransaction = context.Database.BeginTransaction()) { try { var pdfTemplate = new Models.PdfTemplate(); pdfTemplate.ApiKey = GetApiKey(); pdfTemplate.ContactEmail = template.ContactEmail; pdfTemplate.CreatedDate = DateTime.UtcNow; pdfTemplate.DeliveryModeId = template.DeliveryModeId; pdfTemplate.Desc = template.Desc; pdfTemplate.EmailErrorTo = template.EmailErrorTo; pdfTemplate.InputType = template.InputType; pdfTemplate.IsActive = true; pdfTemplate.IsDeleted = false; pdfTemplate.PdfTemplateName = template.PdfTemplateName; pdfTemplate.SampleData = template.SampleData; pdfTemplate.UserId = template.UserId; pdfTemplate.TemplateSections = GetTemplateSections(template.TemplateSections); context.PdfTemplates.Add(pdfTemplate); context.SaveChanges(); dbContextTransaction.Commit(); } catch (Exception) { dbContextTransaction.Rollback(); throw; } } return(SendHttpResponse("Success", HttpStatusCode.OK)); } } catch (Exception e) { return(SendHttpResponse(e.Message, HttpStatusCode.InternalServerError)); } }
public HttpResponseMessage ResetPwdAndEmail(string email) { try { using (var context = new ToPDFDBContext()) { var user = context.Users.FirstOrDefault(c => c.Email == email); if (user != null) { string p = Convert.ToBase64String(Guid.NewGuid().ToByteArray()).Substring(0, 8); user.Password = Convert.ToBase64String(Encoding.ASCII.GetBytes(p)); context.SaveChanges(); SendEmail(p, email); } return(SendHttpResponse("Success", HttpStatusCode.OK)); } } catch (Exception e) { return(SendHttpResponse(e.Message, HttpStatusCode.InternalServerError)); } }
public HttpResponseMessage VerifyEmail(string email) { try { using (var context = new ToPDFDBContext()) { var user = context.Users.FirstOrDefault(c => c.Email == email); if (user != null) { user.EmailVerifiedDate = DateTime.Now; context.SaveChanges(); return(SendHttpResponse("Success", HttpStatusCode.OK)); } else { return(SendHttpResponse("Email Not Found", HttpStatusCode.InternalServerError)); } } } catch (Exception e) { return(SendHttpResponse(e.Message, HttpStatusCode.InternalServerError)); } }