示例#1
0
        //[ChildActionOnly]
        public async Task <PartialViewResult> _DashboardCounter()
        {
            string strUrl     = APIProvider.APIGenerator("Dashboard", "Counter", null);
            var    lstCounter = await APIProvider.Authorize_Get <List <DashboardCounter> >(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CMS, ARS.IgnoredARS);

            return(PartialView("_Counter", lstCounter));
        }
示例#2
0
        public async Task <ActionResult> Edit(Guid id)
        {
            if (!await APIProvider.Authorization(_userSession.BearerToken, ARS.Edit))
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.FuntionType.Permission, APIConstant.ACTION_UPDATE);
                return(RedirectToAction("Index"));
            }
            else
            {
                var model = new PermissionViewModel();
                try
                {
                    var token = _userSession.BearerToken;
                    controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                    //Call API Provider
                    string strUrl = controllerName + "/FindById?id=" + id;
                    model = await APIProvider.Authorize_Get <PermissionViewModel>(token, strUrl, APIConstant.API_Resource_Authorize);

                    if (model != null)
                    {
                        return(View(model));
                    }
                    else
                    {
                        return(View(model));
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex);
                    throw ex;
                }
            }
        }
        // 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;
            }
        }
示例#4
0
        public async Task <ActionResult> Index(string group = "1")
        {
            var model = new ModuleModel();

            try
            {
                //Call API Provider
                controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                var list = await APIProvider.Authorize_Get <List <ModuleViewModel> >(_userSession.BearerToken, controllerName, APIConstant.API_Resource_CORE, ARS.Get);

                model.lstModule = (list == null ? new List <ModuleViewModel>() : list.Where(m => m.Group == group).ToList());

                model.module = new ModuleViewModel();

                ///Category List
                ViewBag.Modules = model.lstModule;
                ViewBag.Group   = group;
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                throw ex;
            }
            return(View(model));
        }
        /// <summary>
        /// Get examine time of a doctor(valid examine time of a doctor)
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="startTime"></param>
        /// <returns></returns>
        public async Task <JsonResult> GetExamineTime(string userId, long startTime)
        {
            var      token = _userSession.BearerToken;
            DateTime date  = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            DateTime start = date.AddMilliseconds(startTime).ToLocalTime();
            //var start = Convert.ToDateTime(startTime);
            var lstAvaiableTime = new List <string>();

            if (start == DateTime.MinValue && start == DateTime.MinValue)
            {
                start = DateTime.Now.AddDays(-2);
            }
            //controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            string apiUrlSchedule = APIProvider.APIGenerator(controllerName, new List <string> {
                nameof(userId),
                nameof(start)
            }, true, userId, start.ToString("yyyy-MM-dd"));
            var schedule = await APIProvider.Authorize_Get <List <ScheduleViewModel> >(token, apiUrlSchedule, APIConstant.API_Resource_CORE, ARS.Detail);

            if (schedule.Count > 0)
            {
                var timeSchedule = schedule.FirstOrDefault();
                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(Json(lstAvaiableTime, JsonRequestBehavior.AllowGet));
        }
示例#6
0
        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);
        }
        public async Task <ActionResult> Services(short departmentId)
        {
            var results = new DepartmentServicesModel();

            results.Services = new DepartmentServicesViewModel();
            try
            {
                //Call API Provider
                string strUrl = APIProvider.APIGenerator(controllerName, new List <string> {
                    "id"
                }, false, departmentId);
                var department = await APIProvider.Authorize_Get <DepartmentViewModel>(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Get);

                //Call API Provider
                strUrl = APIProvider.APIGenerator("DepartmentServices", new List <string> {
                    nameof(departmentId)
                }, true, departmentId);
                var list = await APIProvider.Authorize_Get <List <DepartmentServicesViewModel> >(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Get);

                if (list == null)
                {
                    list = new List <DepartmentServicesViewModel>();
                }
                results.lstServices    = list;
                ViewData["Department"] = department.Name;
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                throw ex;
            }
            return(View(results));
        }
        public async Task <ActionResult> Details(Guid id)
        {
            var apiUrl = "AppointmentLog/" + id;
            var model  = await APIProvider.Authorize_Get <AppointmentLogViewModel>(_userSession.BearerToken, apiUrl, APIConstant.API_Resource_CORE, ARS.Detail);

            if (model != null)
            {
                model.StatusName = (model.Status == 1) ? "Mới đặt hẹn" : (model.Status == 2) ? "Đã khám" : (model.Status == 3) ? "Đã hủy" : "";
                if (model.PhysicianId != string.Empty)
                {
                    var physician = await GetPhysician(model.PhysicianId);

                    model.PhysicianName = physician.Name;
                }
                else
                {
                    model.PhysicianName = Common.ValueConstant.PHYSICIAN_EMPTY;
                }

                var result         = TimeSpan.FromMinutes(model.Time);
                var fromTimeString = result.ToString("hh':'mm");
                model.TimeString = fromTimeString;
            }
            return(PartialView(model));
        }
        // GET: AccessPost/Preview/5
        public async Task <ActionResult> Preview(int id)
        {
            try
            {
                //Call API Provider
                string strUrl = APIProvider.APIGenerator(this, this.RouteData.Values["action"].ToString(), id);
                var    model  = await APIProvider.Authorize_Get <PostViewModel>(_userSession.BearerToken, controllerName + strUrl, APIConstant.API_Resource_CMS, ARS.Get);

                if (string.IsNullOrEmpty(model.Image))
                {
                    model.Image = ValueConstant.IMAGE_PATH + ValueConstant.IMAGE_POST_PATH + ValueConstant.IMAGE_DEFAULT;
                }
                if (model.Tag != string.Empty)
                {
                    ViewBag.Tags = model.Tag;
                }

                return(View(model));
            }
            catch (HttpException ex)
            {
                Logger.LogError(ex);
                int statusCode = ex.GetHttpCode();
                if (statusCode == 401)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(FuntionType.Post, APIConstant.ACTION_ACCESS);
                    return(new HttpUnauthorizedResult());
                }

                throw ex;
            }
        }
        public async Task <ActionResult> Edit(short id)
        {
            if (!await APIProvider.Authorization(_userSession.BearerToken, ARS.Edit))
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.FuntionType.Department, APIConstant.ACTION_UPDATE);
                return(RedirectToAction("Index"));
            }
            else
            {
                var model = new DepartmentViewModel();
                try
                {
                    //Call API Provider
                    string strUrl = APIProvider.APIGenerator(this, this.RouteData.Values["action"].ToString(), id);
                    model = await APIProvider.Authorize_Get <DepartmentViewModel>(_userSession.BearerToken, controllerName + strUrl, APIConstant.API_Resource_CORE, ARS.IgnoredARS);

                    ViewBag.Img = Path.Combine(ValueConstant.IMAGE_DEPARTMENT_PATH, model.Img);
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex);
                    throw ex;
                }
                return(View(model));
            }
        }
        // GET: ApprovePost
        public async Task <ActionResult> Index(PostFilterViewModel param)
        {
            try
            {
                param.LanguageCode = ConfigurationManager.AppSettings["AdminLanguageCode"];

                //Call API Provider
                var listCatg = await APIProvider.Authorize_Get <List <CategoryViewModel> >(_userSession.BearerToken, "Category", APIConstant.API_Resource_CMS, ARS.Get);

                ViewBag.CategoryList = listCatg;

                //Post
                var lstPost = await APIProvider.Authorize_Get <List <PostListViewModel> >(_userSession.BearerToken, "Post", "GetAll", param, APIConstant.API_Resource_CMS, ARS.Get);

                param.PostListViewModel = lstPost;

                return(View(param));
            }
            catch (HttpException ex)
            {
                Logger.LogError(ex);
                int statusCode = ex.GetHttpCode();
                if (statusCode == 401)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(FuntionType.Post, APIConstant.ACTION_ACCESS);
                    return(new HttpUnauthorizedResult());
                }

                throw ex;
            }
        }
        public async Task <ActionResult> Index()
        {
            try
            {
                var token = _userSession.BearerToken;
                controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                string strUrl = controllerName + ConstantDomain.GET_USER_LIST;

                var lstUser = await APIProvider.Authorize_Get <List <UserListViewModel> >(token, strUrl, APIConstant.API_Resource_Authorize, ARS.Get);

                if (lstUser == null)
                {
                    lstUser = new List <UserListViewModel>();
                }

                return(View(lstUser));
            }
            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()
        {
            var token = _userSession.BearerToken;

            //Check add new
            if (!await APIProvider.Authorization(token, ARS.Insert))
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.FuntionType.Account, APIConstant.ACTION_INSERT);
                return(RedirectToAction("Index"));
            }

            var listRole = await APIProvider.Authorize_Get <List <RoleViewModel> >(token, ConstantDomain.GET_ROLE, APIConstant.API_Resource_Authorize, ARS.IgnoredARS);

            if (listRole != null)
            {
                ViewBag.Role = listRole;
            }
            else
            {
                ViewBag.Role = new List <RoleViewModel>();
            }

            RegisterBindingModel model = new RegisterBindingModel();

            return(View(model));
        }
        // GET: EmailMarketing
        public async Task <ActionResult> Index()
        {
            try
            {
                var model = new EmailMarketingViewModel();

                var strUrl    = ControllerName + APIProvider.APIGenerator(this, this.RouteData.Values["action"].ToString());
                var templates = await APIProvider.Authorize_Get <List <EmailMarketingViewModel> >(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Get);

                ViewBag.Templates = templates;

                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> Edit(short id)
        {
            var data = new LinkBuildingViewModel();

            try
            {
                if (!await APIProvider.Authorization(_userSession.BearerToken, ARS.Edit))
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.FuntionType.Account, APIConstant.ACTION_UPDATE);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    //Call API Provider
                    string strUrl = controllerName + APIProvider.APIGenerator(this, this.RouteData.Values["action"].ToString(), id);
                    data = await APIProvider.Authorize_Get <LinkBuildingViewModel>(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CMS, ARS.Get);

                    //var list = await APIProvider.Get<List<LinkBuildingViewModel>>(controllerName);
                }
                return(View(data));
            }
            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> ApprovedBook(string ids, string status)
        {
            ids = ids.Replace("[", "").Replace("]", "").Replace("\"", "");
            if (ids.Length > 0)
            {
                // ids = ids.Replace("[", "").Replace("]", "").Replace("\"", "");
                //var strUrl = $"AppointmentLog/ConfirmFast?ids={ids}&status={status}";
                string apiUrl = APIProvider.APIGenerator("AppointmentLog/ApprovedBook", new List <string> {
                    nameof(ids), nameof(status)
                }, true, ids, status);

                var result = await APIProvider.Authorize_Get <bool>(_userSession.BearerToken, apiUrl, APIConstant.API_Resource_CORE, ARS.IgnoredARS);

                if (result)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_CONFIRM, ApplicationGenerator.TypeResult.SUCCESS));
                }
                else
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_CONFIRM, ApplicationGenerator.TypeResult.FAIL));
                }
            }
            else
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, "Bạn chưa chọn danh sách các phiếu đặt lịch hẹn cần xác nhận");
            }
            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Create()
        {
            if (!await APIProvider.Authorization(_userSession.BearerToken, ARS.Insert))
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.FuntionType.UserProfile, APIConstant.ACTION_INSERT);
                return(RedirectToAction("Index"));
            }
            else
            {
                string   search = string.Empty;
                UserType type   = EnumUserConstants.UserType.ISDOCTOR;
                string   apiUrl = APIProvider.APIGenerator("User", new List <string> {
                    nameof(search), nameof(type)
                }, true, search, type);
                var list = await APIProvider.Authorize_Get <List <UserViewModel> >(_userSession.BearerToken, apiUrl, APIConstant.API_Resource_CORE, ARS.IgnoredARS);

                if (list == null)
                {
                    ViewBag.User = ApplicationGenerator.GetObject <UserViewModel>();
                }
                else
                {
                    ViewBag.User = list;
                }

                return(View());
            }
        }
        /// <summary>
        /// View doctor detail & schedule
        /// </summary>
        /// <param name="doctorId"></param>
        /// <returns></returns>
        public async Task <ActionResult> DoctorSchedule(string doctorId)
        {
            //get doctor
            var    token  = _userSession.BearerToken;
            string id     = doctorId;
            var    doctor = await GetDoctorDetail(id);

            if (doctor == null)
            {
                doctor = new DoctorProfileViewModel();
            }

            var model = new ScheduleUserViewModel();

            //get schedule of doctor
            var    userId         = doctor.UserId;
            var    start          = DateTime.Now;
            var    end            = DateTime.Now.AddDays(2);
            string apiUrlSchedule = APIProvider.APIGenerator(controllerSchedule, new List <string> {
                nameof(userId),
                nameof(start), nameof(end)
            }, true, userId, start.ToString("yyyy-MM-dd"), end.ToString("yyyy-MM-dd"));
            var schedule = await APIProvider.Authorize_Get <List <ScheduleViewModel> >(token, apiUrlSchedule, APIConstant.API_Resource_CORE);

            model.DoctorProfileViewModel = doctor;
            model.lstScheduleViewModel   = schedule;

            return(PartialView("_DoctorDetail", model));
        }
示例#19
0
        public async Task <ActionResult> Edit(short id)
        {
            if (!await APIProvider.Authorization(_userSession.BearerToken, ARS.Edit))
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.FuntionType.Module, APIConstant.ACTION_UPDATE);
                return(RedirectToAction("Index"));
            }
            else
            {
                var model = new ModuleViewModel();
                try
                {
                    //Call API Provider
                    string action = "Get";
                    var    list   = await APIProvider.Authorize_Get <List <ModuleViewModel> >(_userSession.BearerToken, controllerName, APIConstant.API_Resource_CORE, ARS.IgnoredARS);

                    string strUrl = controllerName + '/' + action + '/' + id;
                    model = await APIProvider.Authorize_Get <ModuleViewModel>(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.IgnoredARS);


                    ViewBag.Modules = list.Where(x => x.Id != id && x.Group == model.Group);
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex);
                    throw ex;
                }
                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;
            }
        }
示例#21
0
        public async Task <ActionResult> Delete(short id)
        {
            var model = new ModuleViewModel();

            model.Id = id;
            //Check is used
            string strUrl = controllerName + "/CheckIsUsed" + "/" + id;
            //string strUrl = APIProvider.APIGenerator(controllerName, "CheckIsUsed") + "/" + model.Id;
            var checkIsUsed = await APIProvider.Authorize_Get <bool>(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.IgnoredARS);

            if (!checkIsUsed)
            {
                //Call API Provider - Transaction
                string apiUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_DELETE);
                var    result = await APIProvider.Authorize_DynamicTransaction <ModuleViewModel, bool>(model, _userSession.BearerToken, apiUrl, APIConstant.API_Resource_CORE, 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.ISUSED, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.ISUSED));
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.ERROR, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.ISUSED));
                return(RedirectToAction("Index"));
            }
        }
        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 <ActionResult> Store(string parentId)
        {
            //Initial
            GalleryStoreModel store = new GalleryStoreModel();


            //Call API Provider
            string strUrl = APIProvider.APIGenerator(controllerName, new List <string> {
                "id"
            }, false, parentId);
            var gallery = await APIProvider.Authorize_Get <GalleryViewModel>(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CMS, ARS.Get);

            //Call API Provider
            strUrl = APIProvider.APIGenerator("GalleryStore", new List <string> {
                "parentId"
            }, true, parentId);
            var list = await APIProvider.Authorize_Get <List <GalleryStoreViewModel> >(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CMS, ARS.Get);

            //Uploader
            GalleryUploader uploader = new GalleryUploader();

            uploader.Id    = gallery.Id;
            uploader.Title = gallery.Title;

            //Set
            store.ParentModel     = uploader;
            store.lstGalleryStore = (list == null ? new List <GalleryStoreViewModel>() : list);

            return(View(store));
        }
示例#24
0
        private async Task <List <ArticleCommentViewModel> > GetComments(int id)
        {
            var apiUrl = controllerName + "/GetAllComment?idArticle=" + Convert.ToString(id);
            var model  = await APIProvider.Authorize_Get <List <ArticleCommentViewModel> >(_userSession.BearerToken, apiUrl, APIConstant.API_Resource_CORE, ARS.Get);

            return(model);
        }
        // GET: Survey
        public async Task <ActionResult> Index()
        {
            try
            {
                var model = await APIProvider.Authorize_Get <List <SurveyModel> >(_userSession.BearerToken, ControllerName, APIConstant.API_Resource_CORE, ARS.Get);

                if (model == null)
                {
                    model = ApplicationGenerator.GetObject <List <SurveyModel> >();
                }
                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;
            }
        }
示例#26
0
        // GET: OfferAdvise
        public async Task <ActionResult> Index()
        {
            var model = new OfferAdviseModel();

            try
            {
                //Call API Provider
                controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                List <string> listPara = new List <string> {
                    "patientId", "status"
                };
                var strUrl = APIProvider.APIGenerator(controllerName, listPara, true, _userSession.UserId, (byte)EnumOfferAdviseStatus.ViewAll);
                var list   = await APIProvider.Authorize_Get <List <OfferAdviseViewModel> >(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Get);

                model.lstOfferAdviseViewModel = list;
                model.OfferAdviseViewModel    = new OfferAdviseViewModel();
            }
            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;
            }
            return(View(model));
        }
示例#27
0
        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 APIProvider.Authorize_Get <OfferAdviseViewModel>(_userSession.BearerToken, apiUrl, APIConstant.API_Resource_CORE, ARS.Get);

                //Call API Provider - Transaction
                apiUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_DELETE);
                var result = await APIProvider.Authorize_DynamicTransaction <OfferAdviseViewModel, int>(model, _userSession.BearerToken, apiUrl, APIConstant.API_Resource_CORE, ARS.Delete);

                if (result > 0)
                {
                    ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.SUCCESS));
                }
                else
                {
                    ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.FAIL));
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.FAIL));
                return(View("Index"));
            }
        }
示例#28
0
        public async Task <ActionResult> Edit(short id)
        {
            if (!await APIProvider.Authorization(_userSession.BearerToken, ARS.Insert))
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.FuntionType.OfferAdvise, APIConstant.ACTION_UPDATE);
                return(RedirectToAction("Index"));
            }
            else
            {
                OfferAdviseViewModel model;
                try
                {
                    //Call API Provider
                    var strUrl = controllerName + APIProvider.APIGenerator(this, this.RouteData.Values["action"].ToString(), id);
                    model = await APIProvider.Authorize_Get <OfferAdviseViewModel>(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Edit);

                    if (model.Tag != string.Empty)
                    {
                        ViewBag.Tags = model.Tag;
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex);
                    throw ex.GetBaseException();
                }
                return(View(model));
            }
        }
        // GET: Schedule
        public async Task <ActionResult> Index(ScheduleMultipleViewModel data)
        {
            try
            {
                byte   type   = (byte)EnumUserConstants.UserType.ISDOCTOR;
                string search = "";
                string apiUrl = APIProvider.APIGenerator(controllerUser, new List <string> {
                    nameof(search), nameof(type)
                }, true, search, type);
                var doctorList = await APIProvider.Authorize_Get <List <UserViewModel> >(_userSession.BearerToken, apiUrl, APIConstant.API_Resource_CORE, ARS.Get);

                if (doctorList == null)
                {
                    doctorList = ApplicationGenerator.GetObject <List <UserViewModel> >();
                }
                ViewBag.Users = doctorList;

                if (data.ScheduleFilter == null)
                {
                    data.ScheduleFilter = new ScheduleFilter();
                }
                var param = data.ScheduleFilter;
                //Call API Provider
                if (param.Start == DateTime.MinValue && param.End == DateTime.MinValue)
                {
                    param.Start = DateTime.Now;
                    param.End   = DateTime.Now;
                }
                controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                string apiUrlSchedule = APIProvider.APIGenerator(controllerName, new List <string> {
                    nameof(param.UserId),
                    nameof(param.Start), nameof(param.End)
                }, true, param.UserId, param.Start.ToString("yyyy-MM-dd"), param.End.ToString("yyyy-MM-dd"));
                var schedule = await APIProvider.Authorize_Get <List <ScheduleViewModel> >(_userSession.BearerToken, apiUrlSchedule, APIConstant.API_Resource_CORE, ARS.Get);

                if (schedule.Count == 0)
                {
                    schedule = new List <ScheduleViewModel>();
                }

                ViewBag.Schedule = schedule;

                var schedules = new ScheduleMultipleViewModel();
                var model     = schedules.ScheduleFilter;
                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;
            }
        }
示例#30
0
        //[HttpPost]
        //[AllowAnonymous]
        public async Task <JsonResult> CheckExist(string name, byte id)
        {
            //Call API Provider - Get data
            string apiUrl  = APIProvider.APIGenerator(this, this.RouteData.Values["action"].ToString(), name, id);
            var    isExist = await APIProvider.Authorize_Get <bool>(_userSession.BearerToken, apiUrl, APIConstant.API_Resource_CORE, ARS.IgnoredARS);

            return(Json(!isExist, JsonRequestBehavior.AllowGet));
        }