public async Task <ActionResult> Edit(ArticleViewModel model) { if (ModelState.IsValid) { model.Date = DateTime.Now; model.PatientId = _userSession.UserId; //Call API Provider var strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_UPDATE); var result = await InvokeTransaction(model, strUrl); if (result > 0) { ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.SUCCESS)); } else { ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.FAIL)); } return(RedirectToAction("Index")); } else { ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.FAIL)); return(View(model)); } }
// GET: Feature public async Task <ActionResult> Index() { var results = new SliderModel(); try { //Call API Provider controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); var list = await APIProvider.Authorize_Get <List <SliderViewModel> >(_userSession.BearerToken, controllerName, APIConstant.API_Resource_CMS, ARS.Get); var model = new SliderViewModel() { IsUsed = true }; results.lstSliderViewModel = list; results.SliderViewModel = model; TempData["Data"] = list; return(View(results)); } catch (HttpException ex) { Logger.LogError(ex); int statusCode = ex.GetHttpCode(); if (statusCode == 401) { TempData["Alert"] = ApplicationGenerator.RenderResult(FuntionType.Department, APIConstant.ACTION_ACCESS); return(new HttpUnauthorizedResult()); } throw ex; } }
public async Task <ActionResult> Create(ArticleViewModel model) { if (ModelState.IsValid) { //Set default some fields model.PatientId = _userSession.UserId; model.Status = (byte)ValueConstant.ArticleStatus.JustCreated; model.IsClosed = false; model.Date = DateTime.Now; //Call API Provider string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_INSERT); var result = await InvokeTransaction(model, strUrl); if (result > 0) { //Successful ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS)); } else { //Failed ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL)); } return(RedirectToAction("Index")); } else { return(View(model)); } }
public async Task <HttpResponseMessage> Get(byte pageIndex, byte numberInPage, string Search = null) { try { List <string> list = new List <string> { "pageIndex", "numberInPage", "Search" }; Dictionary <string, dynamic> para = null; para = APIProvider.APIDefaultParameter(list, pageIndex, numberInPage, Search); var data = await _iQARepo.Query(para); var results = new ListQAViewModel(); if (data == null) { results = null; return(Request.CreateResponse(HttpStatusCode.OK, results)); } results.ListViewModel = Mapper.Map <List <QAViewModel> >(data.Item1); results.TotalItem = data.Item2; return(Request.CreateResponse(HttpStatusCode.OK, results)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public async Task <List <string> > GetScheduleExamine(string userId, long startTime) { DateTime date = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); DateTime start = date.AddMilliseconds(startTime).ToLocalTime().Date; //var start = Convert.ToDateTime(startTime); var lstAvaiableTime = new List <string>(); if (start == DateTime.MinValue && start == DateTime.MinValue) { start = DateTime.Now.AddDays(-2); } IList <string> list = new List <string> { "userId", "start" }; var para = APIProvider.APIDefaultParameter(list, userId, start); var source = await _iSchedule.GetScheduleExamine(para); if (source != null) { var timeSchedule = source; lstAvaiableTime.Add(timeSchedule.Start.Hour.ToString() + ":" + timeSchedule.Start.Minute.ToString()); while (timeSchedule.Start <= timeSchedule.End) { timeSchedule.Start = timeSchedule.Start.AddMinutes(15); lstAvaiableTime.Add(timeSchedule.Start.Hour.ToString() + ":" + timeSchedule.Start.Minute.ToString()); } } return(lstAvaiableTime); }
public async Task <List <ScheduleViewModel> > QueryScheduleExamine(string userId, long startTime) { DateTime date = new DateTime(1970, 1, 1); //DateTime start = date.AddMilliseconds(startTime).ToLocalTime(); DateTime startDate = date.AddMilliseconds(startTime); //var start = Convert.ToDateTime(startTime); var lstAvaiableTime = new List <string>(); if (startDate == DateTime.MinValue && startDate == DateTime.MinValue) { startDate = DateTime.Now.AddDays(-2); } IList <string> list = new List <string> { "userId", "start", "End" }; var start = startDate.ToString("yyyy-MM-dd"); var end = startDate.AddDays(2).ToString("yyyy-MM-dd"); var para = APIProvider.APIDefaultParameter(list, userId, start, end); var source = await _iSchedule.QueryScheduleExamine(para); var dest = Mapper.Map <List <ScheduleViewModel> >(source); return(dest); }
public async Task <ActionResult> Delete(int id) { try { //Call API Provider - Get data var apiUrl = controllerName + APIProvider.APIGenerator(this, this.RouteData.Values["action"].ToString(), id); var model = await GetArticle(id); //Call API Provider - Transaction apiUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_DELETE); var result = await InvokeTransaction(model, apiUrl); if (result > 0) { ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.SUCCESS)); return(RedirectToAction("Index")); } else { ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.FAIL)); return(RedirectToAction("Detail", new { id = model.Id })); } } catch (Exception ex) { Logger.LogError(ex); ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.FAIL)); return(View("Index")); } }
private async Task <ArticleViewModel> GetArticle(int id) { var apiUrl = controllerName + APIProvider.APIGenerator(this, this.RouteData.Values["action"].ToString(), id); var model = await APIProvider.Authorize_Get <ArticleViewModel>(_userSession.BearerToken, apiUrl, APIConstant.API_Resource_CORE, ARS.Edit); return(model); }
// GET: Advertise public async Task <ActionResult> Index() { try { var model = new AdvertisesModel(); //Call API Provider controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); var list = await APIProvider.Authorize_Get <List <AdvertiseViewModel> >(_userSession.BearerToken, controllerName, APIConstant.API_Resource_CMS, ARS.Get); model.lstAdvertiseViewModel = list.OrderBy(x => x.Id).ToList(); model.AdvertiseViewModel = new AdvertiseViewModel() { IsUsed = true }; ///Category List ViewBag.Categories = list; TempData["Data"] = list; return(View(model)); } catch (HttpException ex) { Logger.LogError(ex); int statusCode = ex.GetHttpCode(); if (statusCode == 401) { TempData["Alert"] = ApplicationGenerator.RenderResult(FuntionType.Department, APIConstant.ACTION_ACCESS); return(new HttpUnauthorizedResult()); } throw ex; } }
public async Task <ActionResult> Delete(AdvertiseViewModel model) { try { if (!await APIProvider.Authorization(_userSession.BearerToken, ARS.Delete)) { TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.FuntionType.Article, APIConstant.ACTION_DELETE); return(RedirectToAction("Index")); } else { return(PartialView("_Delete", model)); } } catch (HttpException ex) { Logger.LogError(ex); int statusCode = ex.GetHttpCode(); if (statusCode == 401) { TempData["Alert"] = ApplicationGenerator.RenderResult(FuntionType.Department, APIConstant.ACTION_ACCESS); return(new HttpUnauthorizedResult()); } throw ex; } }
public async Task <ActionResult> Delete(byte id) { try { //Call API Provider - Get data string apiUrl = APIProvider.APIGenerator(this, this.RouteData.Values["action"].ToString(), id); var model = await APIProvider.Authorize_Get <AdvertiseViewModel>(_userSession.BearerToken, controllerName + apiUrl, APIConstant.API_Resource_CMS, ARS.Get); if (model == null) { TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.FAIL)); RedirectToAction("Index"); } //Call API Provider - Transaction apiUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_DELETE); var result = await APIProvider.Authorize_DynamicTransaction <AdvertiseViewModel, bool>(model, _userSession.BearerToken, apiUrl, APIConstant.API_Resource_CMS, ARS.IgnoredARS); if (result) { TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.SUCCESS)); } else { TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.FAIL)); } return(RedirectToAction("Index")); } catch (Exception ex) { Logger.LogError(ex); return(View()); } }
public async Task <JsonResult> Push(SystemNotificationEditModel model) { if (ModelState.IsValid) { //Call API Provider string strUrl = APIProvider.APIGenerator("SystemNotification", APIConstant.ACTION_INSERT); model.SendFrom = _userSession.UserId; var result = await APIProvider.Authorize_DynamicTransaction <SystemNotificationEditModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Insert); if (result) { //Call SignalR //Return message var alert = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS)); return(Json(new { IsSuccess = true, Message = model.Detail, Data = alert.ToHtmlString() }, JsonRequestBehavior.AllowGet)); } else { var alert = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL)); return(Json(new { IsSuccess = false, Data = alert.ToHtmlString() }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { IsResult = false, Data = model }, JsonRequestBehavior.AllowGet)); } }
public async Task <HttpResponseMessage> Get(byte id) { var result = await redisCache.GetAsync <FeatureViewModel>(id); if (result == null) { List <string> list = new List <string> { "Id" }; var para = APIProvider.APIDefaultParameter(list, id); var data = await _iFeatureRepo.SingleQuery(para); result = new FeatureViewModel { Id = data.Id, Title = data.Title, Image = LayoutGuide.SPA_ResourcePath(Provider.Common.APIEnums.Application.CMS, data.Image), Description = data.Description, Handler = data.Handler, IsUsed = data.IsUsed }; // await redisCache.AddAsync <FeatureViewModel>(result); } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public async Task<bool> CheckExist(string name, byte id) { var list = this.RequestContext.RouteData.Values.Keys; var para = APIProvider.APIGeneratorParameter(list, id); return await _offeradvise.CheckExist(para); }
/// <summary> /// Performs the query to the provider, passing the required arguments. /// </summary> /// <param name="provider">The API provider to use.</param> /// <param name="callback">The callback invoked on the UI thread after a result has /// been queried.</param> /// <exception cref="System.ArgumentNullException">provider</exception> protected override void QueryAsyncCore(APIProvider provider, APIProvider. ESIRequestCallback <T> callback) { provider.ThrowIfNull(nameof(provider)); provider.QueryPagedEsi <T, U>(Method, callback, wrapped.GetESIParams()); }
public async Task <SystemNotificationModel> GetByUser(string userId, string sendFrom, byte numTop = 0, byte pageIndex = 0, byte numberInPage = 0) { try { if (sendFrom == null) { sendFrom = ""; } var list = new List <string> { "Id", "UserId", "SendFrom", "NumTop", "pageIndex", "numberInPage" }; var para = APIProvider.APIDefaultParameter(list, 0, userId, sendFrom, numTop, pageIndex, numberInPage); var source = await _iSystemNotificationRepo.QueryPaging(para); var dest = Mapper.Map <List <SystemNotificationViewModel> >(source.Item1); dest = dest == null ? new List <SystemNotificationViewModel>() : dest; var result = new SystemNotificationModel(); result.lstUserNotificationViewModel = dest; result.TotalItem = source.Item2; return(result); } catch (Exception ex) { throw ex.GetBaseException(); } }
public async Task <ActionResult> Edit(SettingViewModel model) { var timeStart = TimeSpan.Parse(model.AppointmentStartTimeString); model.AppointmentStartTime = (int)timeStart.TotalMinutes; var timeEnd = TimeSpan.Parse(model.AppointmentEndTimeString); model.AppointmentEndTime = (int)timeEnd.TotalMinutes; if (ModelState.IsValid) { //Call API Provider var strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_UPDATE); var result = await APIProvider.Authorize_DynamicTransaction <SettingViewModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Edit); if (result) { TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.SUCCESS)); } else { TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.FAIL)); } } else { TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.ERROR, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.ERROR)); } return(RedirectToAction("Index")); }
public void Init(APIProvider provider) { this.provider = provider; textBoxUrl.Text = string.Format(@"https://raw.github.com/QuantBox/OpenQuant-CTP/master/{0}.Brokers.xml", provider.Name); }
public APIService(APIProvider provider) { _APIProvider = provider; }