public HttpResponseMessage Delete(DateTime diaryid) { try { var diaryTodelete = TheRepository.GetDiary(_identityService.CurrentUser, diaryid); if (diaryTodelete == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } if (TheRepository.DeleteDiary(diaryTodelete.Id) && TheRepository.SaveAll()) { return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } } catch (Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e.ToString())); } }
public HttpResponseMessage Put(int id, [FromBody] CourseModel courseModel) { try { var updatedCourse = TheModelFactory.Parse(courseModel); if (updatedCourse == null) { Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not read subject/tutor from body"); } var originalCourse = TheRepository.GetCourse(id); if (originalCourse == null || originalCourse.Id != id) { return(Request.CreateResponse(HttpStatusCode.NotModified, "Course is not found")); } else { updatedCourse.Id = id; } if (TheRepository.Update(originalCourse, updatedCourse) && TheRepository.SaveAll()) { return(Request.CreateResponse(HttpStatusCode.OK, TheModelFactory.Create(updatedCourse))); } else { return(Request.CreateResponse(HttpStatusCode.NotModified)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public ActionResult Index() { var invoices = TheRepository.GetInvoices(); return(View(invoices)); }
public IEnumerable <MeasureModel> Get(int foodid) { var results = TheRepository.GetMeasuresForFood(foodid).ToList().Select(m => TheModelFactory.Create(m)); return(results); }
public IQueryable GetClients(Guid firmid) { return(TheRepository.GetClient(firmid)); }
public IActionResult Services() { var model = TheRepository.GetServices(); return(View(model)); }
public FoodModel Get(int foodid) { return(TheModelFactory.Create(TheRepository.GetFood(foodid))); }
public BookWithTagsV2Model Get(int bookid) { return((BookWithTagsV2Model)TheModelFactory.Create2(TheRepository.GetBook(bookid))); }
public IActionResult CustSignupProcess(CustomerModel model) { model.isActive = true; // should be after user has validated their email. but temp for now model.VerifyCode = Guid.NewGuid().ToString(); var exist = TheRepository.CheckEmailExist(model.emailAddress); if (exist) { TempData["exist"] = "Email Exists"; return(View("CustSignup", model)); } var customer = TheRepository.CreateCustomer(model); model.id = customer.id; model.emailConfirmed = false; model.isRegistrationApproved = false; model.createdDate = DateTime.Now; model.password = PasswordHash.PasswordHash.CreateHash(model.password).Replace("1000:", String.Empty); LoginModel login = new LoginModel { userName = model.emailAddress, password = model.password, userid = customer.id, createdDate = DateTime.Now }; var createdLogin = TheRepository.CreateLogin(login); var encryptedid = EncryptionUtility.Encrypt(createdLogin.id.ToString()); //Send an authorisation email to the customer EmailInfo emailInfo = new EmailInfo(); var callbackUrl = Url.Action("VerifyEmail", "CustomerSignup", new { userId = customer.id, code = model.VerifyCode }, Request.Scheme, Request.Host.Value + "/CustomerArea"); emailInfo.Body = $"Welcome from I NEED YOUR TIME. Click <a href='{callbackUrl}'>here</a> to confirm your email"; emailInfo.emailType = "WelcomeEmail"; emailInfo.IsBodyHtml = true; emailInfo.Subject = "Welcome to INYT"; emailInfo.ToAddress = model.emailAddress; //_emailManager.SendEmail(emailInfo); var model2 = new Emailmodel { Name = model.firstName, Body = emailInfo.Body }; var renderedHTML = ControllerExtensions.RenderViewAsHTMLString(this, "_VerifyEmail.cshtml", model2); EmailManager.SendEmail2(model.emailAddress, "VerifyAccount", renderedHTML.Result); //SendSimpleMessage(String.Format("<strong>Welcome from I NEED YOUR TIME. Click <a href='CustomerSignup/ConfirmEmail/{0}'>here</a> to confirm your email", "*****@*****.**"), encryptedid).Content.ToString(); //Send an email to the Administrator with the customer details //EmailInfo emailInfo = new EmailInfo(); emailInfo.Body = "New customer on INYT website"; emailInfo.emailType = "NewCustomerEmail"; emailInfo.IsBodyHtml = true; emailInfo.Subject = "New customer"; emailInfo.ToAddress = "*****@*****.**"; _emailManager.SendEmail(emailInfo); var model_admin = new Emailmodel { Name = model.firstName, Body = emailInfo.Body }; var renderedHTMLAdmin = ControllerExtensions.RenderViewAsHTMLString(this, "_AdminEmail.cshtml", model_admin); EmailManager.SendEmail2(model.emailAddress, "VerifyAccount", renderedHTMLAdmin.Result); //SendSimpleMessage("New customer on INYT website", "*****@*****.**").Content.ToString(); return(View(model)); }
public IActionResult Membership() { var memberships = TheRepository.GetMemberships(); return(View(memberships)); }
public IHttpActionResult Get(int foodid) { return(Versioned(TheModelFactory.Create(TheRepository.GetFood(foodid)), "v2")); }
public IHttpActionResult Get(int id) { return(Ok(TheModelFactory.CreateUser(TheRepository.GetUserByUserId(id)))); }
public IHttpActionResult Get() { return(Ok(TheRepository.GetAllUsers().ToList().Select(x => TheModelFactory.CreateUser(x)).ToList())); }
public IQueryable <AnyNameListDTO> Get() { //Your other Code will go here Session["AnyName"] = TheRepository.YourMethodName(); }
public ActionResult DeleteConfirmed(ProductForDeleteDto product) { TheRepository.RemoveProductFromInvoice(product.InvoiceId, product.ProductId); return(RedirectToAction("Details", "Details", new { id = product.InvoiceId })); }
public bool Get(string userName) { return(TheRepository.UserNameExists(userName)); }
public HttpResponseMessage Get(int id) { return(Request.CreateResponse( HttpStatusCode.OK, TheModelFactory.Create(TheRepository.GetFood(id)))); }
public ActionResult Get() { //Your other Code will go here Session["AnyName"] = TheRepository.YourMethodName(); }
public IActionResult Customers() { var model = TheRepository.GetCustomers(); return(View(model)); }
public ActionResult BookStep2(BookingModel model) { var selectedTimes = Request.Form["selectedTimes"].ToString(); BookingsListModel bookingsList = new BookingsListModel(); foreach (var selectedTime in selectedTimes.Split(',')) { if (!String.IsNullOrEmpty(selectedTime)) { var bookingAmount = Convert.ToInt32(selectedTime.Split('_')[0].ToString()); var requestedDate = Convert.ToDateTime(selectedTime.Split('_')[1].ToString()); var requestedTime = Convert.ToDateTime(selectedTime.Split('_')[2].ToString().Replace('-', ':')); var requestedDay = selectedTime.Split('_')[2].ToString(); model.bookingDate = new DateTime(requestedDate.Year, requestedDate.Month, requestedDate.Day, requestedTime.Hour, requestedTime.Minute, requestedTime.Second); model.bookingTime = new DateTime(requestedDate.Year, requestedDate.Month, requestedDate.Day, requestedTime.Hour, requestedTime.Minute, requestedTime.Second); model.bookingAmount = bookingAmount; model.serviceProviderId = Convert.ToInt32(Request.Form["serviceProviderId"]); model.serviceId = Convert.ToInt32(Request.Form["serviceId"]); int hours = TheRepository.GetMinHours(model.serviceProviderId, requestedDate.DayOfWeek.ToString()); int customerid = 0; if (TheRepository.GetCustomerByEmail(model.customer.emailAddress) == null) { var cust = TheRepository.CreateCustomer(model.customer); customerid = cust.id; } else { customerid = TheRepository.GetCustomerByEmail(model.customer.emailAddress).id; } model.customerId = customerid; model.bookingHours = hours; var newBooking = TheRepository.CreateBooking(model); int newBookingId = newBooking.id; if (newBooking != null) { foreach (var answer in model.additionalQuestionsList) { answer.customerId = customerid; answer.serviceId = model.serviceId; TheRepository.CreateAdditionalQuestions(answer); } } model.id = newBooking.id; } } List <BookingModel> bookings = new List <BookingModel>(); bookings = TheRepository.GetAllBookingsByCustomer(model.customerId); bookingsList.bookings = bookings.Where(a => a.bookingAccepted == false).ToList(); bookingsList.serviceProvider = TheRepository.GetServiceProvider(model.serviceProviderId); return(View("ConfirmPayment", bookingsList)); }
public IActionResult AddService(ServiceModel model) { TheRepository.CreateService(model); return(RedirectToAction("services")); }