public async Task <IActionResult> AddStudent(int id) { if (int.TryParse(Request.Form["StudentId"], out var studentId) && Enum.TryParse <LetterGrade>(Request.Form["LetterGrade"], out var letterGrade)) { var student = await studentService.GetAsync(studentId); var course = await courseService.GetAsync(id); if (course != null && student != null) { var preexisting = ctx.Enrollments .Where(e => e.CourseId == id && e.StudentId == studentId) .FirstOrDefault(); if (preexisting == null) { await ctx.Enrollments.AddAsync(new Enrollment() { StudentId = studentId, CourseId = id, Grade = letterGrade }); } else if (preexisting.Grade != letterGrade) { preexisting.Grade = letterGrade; ctx.Enrollments.Update(preexisting); } await ctx.SaveChangesAsync(); } } return(RedirectToAction("View", new { Id = id })); }
public async Task <ActionResult <IEnumerable <OrderDto> > > GetOrder(int id) { try { var order = await m_ordersService.GetAsync(id); return(Ok(order)); } catch (Exception) { return(StatusCode(500)); } }
private async Task <Notification> EditSector(SectorDTO sectorDTO, IdentityUser user) { try { var record = await _sectorCrudService.GetAsync(sectorDTO.Sector.Id); record.Name = sectorDTO.Sector.Name; record.Code = sectorDTO.Sector.Code; record.ModifiedBy = user.Id; record.ModifiedDate = DateTime.Now; foreach (var sectorTransport in sectorDTO.SectorTransport) { var recordST = await _sectorTransportCrudService.GetAsync(p => p.SectorId == sectorDTO.Sector.Id && p.TransportId == sectorTransport.TransportId); recordST.Cost = sectorTransport.Cost; recordST.ModifiedBy = user.Id; record.ModifiedDate = DateTime.Now; _sectorTransportCrudService.Update(recordST); } _sectorCrudService.Update(record); return(new Notification("success", "Sector updated successfully.")); } catch (Exception exception) { Console.WriteLine(exception.Message); return(new Notification("error", "Sector update failed.")); } }
private async Task <Notification> EditHotelRoomRate(HotelRoomRate hotelRoomRate, IdentityUser user) { try { var record = await _hotelRoomRateCrudService.GetAsync(hotelRoomRate.Id); record.HotelId = hotelRoomRate.HotelId; record.SingleBed = hotelRoomRate.SingleBed; record.DoubleBed = hotelRoomRate.DoubleBed; record.ExtraBed = hotelRoomRate.ExtraBed; record.AP = hotelRoomRate.AP; record.MAP = hotelRoomRate.MAP; record.ModifiedBy = user.Id; record.ModifiedDate = DateTime.Now; _hotelRoomRateCrudService.Update(record); return(new Notification("success", "Hotel Room Rate updated successfully.")); } catch (Exception exception) { Console.WriteLine(exception.Message); return(new Notification("error", "Hotel Room Rate update failed.")); } }
public virtual async Task TryToSendOrderNotificationsAsync(OrderNotificationJobArgument[] jobArguments) { var ordersByIdDict = (await _customerOrderService.GetAsync(jobArguments.Select(x => x.CustomerOrderId).Distinct().ToList())) .ToDictionary(x => x.Id) .WithDefaultValue(null); foreach (var jobArgument in jobArguments) { var notification = await _notificationSearchService.GetNotificationAsync(jobArgument.NotificationTypeName, new TenantIdentity(jobArgument.StoreId, nameof(Store))); if (notification != null) { var order = ordersByIdDict[jobArgument.CustomerOrderId]; if (order != null && notification is CustomerReviewEmailNotification orderNotification) { var customer = await _memberResolver.ResolveMemberByIdAsync(jobArgument.CustomerId); orderNotification.Item = order.Items.FirstOrDefault(i => i.ProductId == jobArgument.ProductId); orderNotification.Customer = customer; orderNotification.RequestId = jobArgument.RequestId; orderNotification.LanguageCode = order.LanguageCode; await SetNotificationParametersAsync(notification, order, customer); await _notificationSender.ScheduleSendNotificationAsync(notification); } } } }
//Edit Service Voucher private async Task <Notification> EditServiceVoucher(ServiceVoucher serviceVoucher, IdentityUser user) { try { var record = await _serviceVoucherCrudService.GetAsync(serviceVoucher.Id); record.FileCodeNo = serviceVoucher.FileCodeNo; record.HotelId = serviceVoucher.HotelId; record.ClientName = serviceVoucher.ClientName; record.PAX = serviceVoucher.PAX; record.ArrivalDate = serviceVoucher.ArrivalDate; record.From = serviceVoucher.From; record.ArrivalFlight = serviceVoucher.ArrivalFlight; record.DepartureDate = serviceVoucher.DepartureDate; record.To = serviceVoucher.To; record.DepartureFlight = serviceVoucher.DepartureFlight; record.Services = serviceVoucher.Services; record.ModifiedBy = user.Id; record.ModifiedDate = DateTime.Now; _serviceVoucherCrudService.Update(record); return(new Notification("success", "Service Voucher updated successfully.")); } catch (Exception exception) { Console.WriteLine(exception.Message); return(new Notification("error", "Service Voucher update failed.")); } }
private async Task <Notification> EditInvoice(Invoice invoice, IdentityUser user) { try { _unitOfWork.BeginTransaction(); var record = await _invoiceCrudService.GetAsync(invoice.Id); record.IsTicket = invoice.IsTicket; record.ReferenceNo = invoice.ReferenceNo; record.Dr = invoice.Dr; record.FileCodeNo = invoice.FileCodeNo; record.Address = invoice.Address; record.ClientName = invoice.ClientName; record.Currency = invoice.Currency; record.PAX = invoice.PAX; record.Guide = invoice.Guide; record.Vehicle = invoice.Vehicle; record.TotalDue = invoice.TotalDue; record.Discount = invoice.Discount; record.NetAmount = invoice.NetAmount; record.ModifiedBy = user.Id; record.ModifiedDate = DateTime.Now; var invoiceDetails = _invoiceDetailCrudService.GetAll(p => p.InvoiceId == invoice.Id); foreach (InvoiceDetail invoiceDetail in invoiceDetails) { if (!invoice.InvoiceDetails.Any(x => x.Id == invoiceDetail.Id)) { _invoiceDetailCrudService.Delete(invoiceDetail); } } foreach (InvoiceDetail invoiceDetail in invoice.InvoiceDetails) { if (!invoiceDetails.Contains(invoiceDetail)) { await _invoiceDetailCrudService.InsertAsync(new InvoiceDetail { InvoiceId = invoice.Id, Particulars = invoiceDetail.Particulars, Amount = invoiceDetail.Amount, CreatedBy = user.Id }); } } _invoiceCrudService.Update(record); _unitOfWork.Commit(); return(new Notification("success", "Invoice updated successfully.")); } catch (Exception exception) { Console.WriteLine(exception.Message); _unitOfWork.Rollback(); return(new Notification("error", "Invoice update failed.")); } }
private async Task <Notification> EditCustomer(Customer customer, IdentityUser user) { try { var record = await _customerCrudService.GetAsync(customer.Id); record.TourName = customer.TourName; record.Country = customer.Country; record.ArrivalDate = customer.ArrivalDate; record.DepartureDate = customer.DepartureDate; record.Agent = customer.Agent; record.AgentStaff = customer.AgentStaff; record.GuideName = customer.GuideName; record.ModifiedDate = DateTime.Now; _customerCrudService.Update(record); return(new Notification("success", "Customer updated successfully.")); } catch (Exception exception) { Console.WriteLine(exception.Message); return(new Notification("error", "Customer update failed.")); } }
public async Task <IViewComponentResult> InvokeAsync(string type) { ViewBag.Type = type; var result = await _systemSettingService.GetAsync(x => x.Id == 1, new string[] { }); return(View(result.Data ?? new Data.Context.SystemSetting())); }
public virtual async Task TryToSendOrderNotificationsAsync(OrderRequestReviewJobArgument[] jobArguments) { var ordersByIdDict = (await _orderService.GetAsync(jobArguments.Select(x => x.CustomerOrderId).Distinct().ToList())) .ToDictionary(x => x.Id) .WithDefaultValue(null); using (var repository = _customerReviewRepository()) { foreach (var jobArgument in jobArguments) { var order = ordersByIdDict[jobArgument.CustomerOrderId]; if (order != null) { foreach (var item in order.Items) { repository.Add(new RequestReviewEntity() { CreatedDate = DateTime.Now, CustomerOrderId = jobArgument.CustomerOrderId, ModifiedDate = DateTime.Now, ProductId = item.ProductId, ReviewsRequest = 0, StoreId = jobArgument.StoreId, UserId = jobArgument.CustomerId }); } } } await repository.UnitOfWork.CommitAsync(); } }
public async Task <IActionResult> View(int id) { var jobApplication = await _jobApplicationService.GetAsync(x => x.Id == id, new string[] { "JobApplicationEducation", "JobApplicationExperience" }); await FillLists(jobApplication.Data); return(View(jobApplication.Data ?? new JobApplication())); }
public virtual async Task <IActionResult> Get(int id) { var result = await baseService.GetAsync(id); return(result != null ? Ok(result) : (IActionResult)NotFound()); }
public async Task <IActionResult> AddEdit(int?id) { TourcostDTO tourcost = new TourcostDTO(); if (id > 0) { tourcost.Tourcost = await _tourcostCrudService.GetAsync(id); tourcost.TourcostDetail = _tourcostDetailCrudService.GetAll(p => p.TourcostId == id).ToList(); } ViewBag.Guide = new SelectList(await _guideCrudService.GetAllAsync(), "Id", "Name"); ViewBag.Sector = new SelectList(await _sectorCrudService.GetAllAsync(), "Id", "Name"); ViewBag.HotelCatA = new SelectList(await _hotelCrudService.GetAllAsync(p => p.Category == 'A'), "Id", "Code"); ViewBag.HotelCatB = new SelectList(await _hotelCrudService.GetAllAsync(p => p.Category == 'B'), "Id", "Code"); ViewBag.HotelCatC = new SelectList(await _hotelCrudService.GetAllAsync(p => p.Category == 'C'), "Id", "Code"); return(View(tourcost)); }
public async Task <IActionResult> AddEdit(HomeSlide homeSlide) { try { if (ModelState.IsValid) { var _homeSlide = _mapper.Map <HomeSlide>(homeSlide); var dbSlide = await _homeSlideService.GetAsync(x => x.Id == homeSlide.Id, new string[] { }); if (dbSlide?.Data != null) { _homeSlide.CreateDate = dbSlide.Data.CreateDate; _homeSlide.SlidePath = dbSlide.Data.SlidePath; } else { _homeSlide.CreateDate = DateTime.Now; } if (Request.Form.Files.Count > 0) { _homeSlide.SlidePath = SaveFile(_hostingEnvironment.ContentRootPath, "homeSlider"); } if (homeSlide.Id == 0) { homeSlide.UserId = CurrentUser.UserId; } var result = _homeSlide.Id == 0 ? await _homeSlideService.CreateAsync(homeSlide) : await _homeSlideService.EditAsync(homeSlide); return(Json(result)); } } catch (Exception ex) { return(Json(Result.Create(false, ex.Message, 500))); } return(Json(Result.Create(false, 500))); }
public async Task <IActionResult> AddEdit(News news) { try { if (ModelState.IsValid) { var _news = _mapper.Map <News>(news); var dbNews = await _newsService.GetAsync(x => x.Id == news.Id, new string[] { }); news.SeoFriendlyUrl = SeoFriendlyUrlHelper.GetFriendlyTitle(string.IsNullOrEmpty(news.SeoFriendlyUrl) ? news.Title : news.SeoFriendlyUrl); if (news.Id == 0) { news.CreateDate = DateTime.Now; news.UserId = CurrentUser.UserId; } else { news.CreateDate = dbNews.Data.CreateDate; } if (Request.Form.Files.Count > 0) { news.Image = SaveFile(_hostingEnvironment.ContentRootPath, "images/news", true); } news.Body = string.IsNullOrEmpty(news.Body) ? "<p></p>" : news.Body; var result = _news.Id == 0 ? await _newsService.CreateAsync(news) : await _newsService.EditAsync(news); return(Json(result)); } } catch (Exception ex) { return(Json(Result.Create(false, ex.Message, 500))); //ToDo log } return(Json(Result.Create(false, 500))); }
public async Task <IActionResult> Detail(string title, int page = 1) { ViewBag.SlidePath = _configuration["header-slide:news"]; ViewBag.MobileSlidePath = _configuration["header-slide:news_mobile"]; var result = await _newsService.GetAsync(x => x.SeoFriendlyUrl == title, new string[] { }); ViewBag.Start = (page - 1) * 10; ViewBag.PageSize = 10; ViewBag.Page = page; ViewBag.List = await _newsService.GetListAsync((page - 1) * 10, 10, null, "CreateDate", true, new string[] { }); ViewBag.TotalItems = ViewBag.List.AllCount; return(View(result)); }
public async Task <IHttpActionResult> GetPostAsync(int?id) { if (id == null) { return(BadRequest()); } Post post = await _postService.GetAsync(id); if (post == null) { return(NotFound()); } return(Ok(post)); }
public async Task <ActionResult <ProductDto> > PostProduct(ProductDto product) { var transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); try { var insertedProduct = await m_productsService.AddAsync(product); var productsHelper = new ProductIngredientHelper(m_productIngredientService); await productsHelper.AddIngredientsAsync(insertedProduct.Id, product.Ingredients); var targetProduct = await m_productsService.GetAsync(insertedProduct.Id); transaction.Complete(); return(CreatedAtAction ( nameof(GetProduct), new { id = targetProduct.Id }, targetProduct )); } catch (Exception ex) { return(StatusCode(500)); } finally { transaction.Dispose(); } }
public async Task <ActionResult <CategoryDto> > Get(int id) { try { var category = await categoryService.GetAsync(id); if (category == null) { return(NotFound()); } return(Ok(category)); } catch (Exception e) { return(StatusCode(500, e)); } }
public async Task <ActionResult <OrderStatusDto> > Get(int id) { try { var orderStatus = await orderStatusService.GetAsync(id); if (orderStatus == null) { return(NotFound()); } return(Ok(orderStatus)); } catch (Exception ex) { return(StatusCode(500, ex)); } }
public async Task <ActionResult <IngredientDto> > Get(int id) { try { var ingredient = await ingredientService.GetAsync(id); if (ingredient == null) { return(NotFound()); } return(Ok(ingredient)); } catch (Exception e) { return(StatusCode(500, e)); } }
private async Task <Notification> EditTransport(Transport transport, IdentityUser user) { try { var record = await _transportCrudService.GetAsync(transport.Id); record.Name = transport.Name; record.MinPAX = transport.MinPAX; record.MaxPAX = transport.MaxPAX; record.ModifiedBy = user.Id; record.ModifiedDate = DateTime.Now; _transportCrudService.Update(record); return(new Notification("success", "Transport updated successfully.")); } catch (Exception exception) { Console.WriteLine(exception.Message); return(new Notification("error", "Transport update failed.")); } }
private async Task <Notification> EditGuide(Guide guide, IdentityUser user) { try { var record = await _guideCrudService.GetAsync(guide.Id); record.Name = guide.Name; record.FullDayRate = guide.FullDayRate; record.HalfDayRate = guide.HalfDayRate; record.OverNight = guide.OverNight; record.ModifiedBy = user.Id; record.ModifiedDate = DateTime.Now; _guideCrudService.Update(record); return(new Notification("success", "Guide updated successfully.")); } catch (Exception exception) { Console.WriteLine(exception.Message); return(new Notification("error", "Guide update failed.")); } }
public async Task <ActionResult <CustomerReviewListItemSearchResult> > GetCustomerReviewsList([FromBody] CustomerReviewSearchCriteria criteria) { var reviews = await _customerReviewSearchService.SearchAsync(criteria); var storeIds = reviews.Results .Select(r => r.StoreId) .Distinct() .ToList(); var stores = await _storeService.GetAsync(storeIds); var productIds = reviews.Results .Select(r => r.ProductId) .Distinct() .ToArray(); var products = await _itemService.GetByIdsAsync(productIds, ItemResponseGroup.None.ToString()); var results = new List <CustomerReviewListItem>(); foreach (var review in reviews.Results) { var listItem = new CustomerReviewListItem(review) { StoreName = stores.FirstOrDefault(s => s.Id == review.StoreId)?.Name, ProductName = products.FirstOrDefault(p => p.Id == review.ProductId)?.Name }; results.Add(listItem); } var retVal = new CustomerReviewListItemSearchResult { Results = results, TotalCount = reviews.TotalCount }; return(Ok(retVal)); }
private async Task <Notification> EditHotel(Hotel hotel, IdentityUser user) { try { var record = await _hotelCrudService.GetAsync(hotel.Id); record.Name = hotel.Name; record.Address = hotel.Address; record.PhoneNo = hotel.PhoneNo; record.Code = hotel.Code; record.Category = hotel.Category; record.ModifiedBy = user.Id; record.ModifiedDate = DateTime.Now; _hotelCrudService.Update(record); return(new Notification("success", "Hotel updated successfully.")); } catch (Exception exception) { Console.WriteLine(exception.Message); return(new Notification("error", "Hotel update failed.")); } }
public async Task <IEnumerable <CourseDTO> > GetCourses() { var courses = await _crudService.GetAsync <Course, CourseDTO>(); return(courses); }
public async Task <IActionResult> View(int id) { var contactUs = await _contactUsService.GetAsync(x => x.Id == id, new string[] { }); return(View(contactUs.Data ?? new ContactUs())); }
public async Task <IEnumerable <InstructorDTO> > GetInstructors() { var instructors = await _crudService.GetAsync <Instructor, InstructorDTO>(); return(instructors); }
public async Task <IEnumerable <ModuleDTO> > GetModules() { var modules = await _crudService.GetAsync <Module, ModuleDTO>(); return(modules); }
public async Task <IEnumerable <VideoDTO> > GetVideos() { var videos = await _crudService.GetAsync <Video, VideoDTO>(); return(videos); }