public async Task <ActionResult> ServicesDelete(short id, short departmentId)
        {
            try
            {
                var model = new DepartmentServicesViewModel();
                model.Id           = id;
                model.DepartmentId = departmentId;

                //Call API Provider
                string strUrl = APIProvider.APIGenerator("DepartmentServices", APIConstant.ACTION_DELETE);
                var    result = await APIProvider.Authorize_DynamicTransaction <DepartmentServicesViewModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Delete);

                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("Services", new { departmentId = departmentId }));
            }
            catch (Exception ex)
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.FAIL));
                Logger.LogError(ex);
                return(RedirectToAction("Services", new { departmentId = departmentId }));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Edit(OfferAdviseViewModel model)
        {
            model.Date      = DateTime.Now;
            model.PatientId = _userSession.UserId;
            if (ModelState.IsValid)
            {
                //Call API Provider
                var strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_UPDATE);
                var result = await APIProvider.Authorize_DynamicTransaction <OfferAdviseViewModel, int>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Edit);

                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));
                if (model.Tag != null)
                {
                    ViewBag.Tags = model.Tag;
                }
                return(View(model));
            }
        }
Exemplo n.º 3
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));
        }
        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> Delete(int id)
        {
            if (id > 0)
            {
                controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_DELETE);

                var model = new CreateScheduleViewModel();
                model.Detail = string.Empty;
                model.Title  = string.Empty;
                model.UserId = string.Empty;
                model.Color  = string.Empty;
                model.Start  = DateTime.Now;
                model.End    = DateTime.Now;
                model.Id     = id;
                var result = await APIProvider.Authorize_DynamicTransaction <CreateScheduleViewModel, int>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.IgnoredARS);

                if (result > 0)
                {
                    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"));
            }
            else
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.FAIL));
                return(View("Index"));
            }
        }
Exemplo n.º 6
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 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"));
            }
        }
        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"));
        }
Exemplo n.º 8
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));
        }
Exemplo n.º 9
0
        public ActionResult _Nav()
        {
            ModuleShared lstModel = new ModuleShared();


            //Get from cookie
            //List<ModuleApplication> model = CookieStore.Get<List<ModuleApplication>>(APIConstant.COOKIE_MODULE + APIConstant.MODULE_CMS, HttpContext.ApplicationInstance.Context);
            //if (model != null)
            //{
            //    lstModel.lstModuleParent = model.Where(x => x.ParentId == 0).ToList();
            //    lstModel.lstModuleItem = model.Where(x => x.ParentId != 0).ToList();
            //}

            string strUrl = APIProvider.APIGenerator("Module", "Initial", new List <string> {
                "group"
            }, true, APIConstant.MODULE_CMS);
            var lstModule = APIProvider.Authorize_GetNonAsync <List <ModuleApplication> >(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.IgnoredARS);

            if (lstModule != null)
            {
                lstModel.lstModuleParent = lstModule.Where(x => x.ParentId == 0).ToList();
                lstModel.lstModuleItem   = lstModule.Where(x => x.ParentId != 0).ToList();
            }

            return(PartialView("_Nav", lstModel));
        }
Exemplo n.º 10
0
        public async Task <ActionResult> Edit(ModuleViewModel model)
        {
            //Ignored
            ModelState["ParentId"].Errors.Clear();

            if (ModelState.IsValid)
            {
                //Call API Provider
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_UPDATE);
                var    result = await APIProvider.Authorize_DynamicTransaction <ModuleViewModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.IgnoredARS);

                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));
                }
                return(RedirectToAction("Index", new { group = model.Group }));
            }
            else
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.ERROR, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.ERROR));
                return(RedirectToAction("Edit", model.Id));
            }
        }
Exemplo n.º 11
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> 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());
            }
        }
        public async Task <ActionResult> Edit(LinkBuildingViewModel model)
        {
            if (ModelState.IsValid)
            {
                //Call API Provider
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_UPDATE);
                var    result = await APIProvider.Authorize_DynamicTransaction <LinkBuildingViewModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CMS, ARS.IgnoredARS);

                if (result)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.SUCCESS));
                }
                else
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.ERROR, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.ERROR));
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                var links = new LinkBuildingModel();
                links.lstLinkBuildingViewModel = (List <LinkBuildingViewModel>)TempData["Data"];
                links.LinkBuildingViewModel    = model;

                TempData["Data"] = links.lstLinkBuildingViewModel;
                return(View("Index", links));
            }
        }
        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;
            }
        }
Exemplo n.º 15
0
        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));
            }
        }
Exemplo n.º 16
0
        public async Task <ActionResult> Approve(PostStateHistoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    model.UserId = _userSession.UserId;

                    //Call API Provider
                    string strUrl = APIProvider.APIGenerator("Post/Approve", APIConstant.ACTION_UPDATE);
                    var    result = await APIProvider.Authorize_DynamicTransaction <PostStateHistoryViewModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CMS, ARS.IgnoredARS);

                    if (result == true)
                    {
                        TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS_APPROVE, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_APPROVE, ApplicationGenerator.TypeResult.SUCCESS_APPROVE));
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL_APPROVE, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_APPROVE, ApplicationGenerator.TypeResult.FAIL_APPROVE));
                        return(RedirectToAction("Index"));
                    }
                }
                catch
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.ERROR, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_APPROVE, ApplicationGenerator.TypeResult.ERROR));
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL_APPROVE, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_APPROVE, ApplicationGenerator.TypeResult.FAIL_APPROVE));
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 17
0
        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));
            }
        }
Exemplo n.º 18
0
        public async Task <ActionResult> Delete(string id)
        {
            try
            {
                var model = new GalleryViewModel();
                model.Id = id;

                //Call API Provider
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_DELETE);
                var    result = await APIProvider.Authorize_DynamicTransaction <GalleryViewModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CMS, ARS.Get);

                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(RedirectToAction("Index"));
            }
        }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
0
        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));
        }
Exemplo n.º 21
0
        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));
            }
        }
Exemplo n.º 22
0
        public async Task <ActionResult> Edit(LanguageViewModel model, HttpPostedFileBase fileUpload)
        {
            if (ModelState.IsValid)
            {
                if (fileUpload != null)
                {
                    model.Icon = FileManagement.ImageToByteArray(fileUpload);
                }

                //Call API Provider
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_UPDATE);
                var    result = await APIProvider.Authorize_DynamicTransaction <LanguageViewModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CMS, ARS.IgnoredARS);

                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));
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.FAIL));
                return(View());
            }
        }
Exemplo n.º 23
0
        public async Task <ActionResult> Edit(ScheduleMultipleViewModel param)
        {
            if (ModelState.IsValid)
            {
                controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_UPDATE);

                var model = param.CreateScheduleViewModel;
                model.Start = DateTime.Parse(model.StartDate.Split('T')[0] + " " + model.StartTime);
                model.End   = DateTime.Parse(model.StartDate.Split('T')[0] + " " + model.EndTime);
                model.Color = string.Empty;
                var result = await APIProvider.Authorize_DynamicTransaction <CreateScheduleViewModel, int>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.IgnoredARS);

                if (result > 0)
                {
                    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));
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.FAIL));
                return(View("Index"));
            }
        }
        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"));
        }
Exemplo n.º 25
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));
            }
        }
        /// <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));
        }
Exemplo n.º 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"));
            }
        }
        /// <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));
        }
Exemplo n.º 29
0
        public async Task <ActionResult> Details(ArticlesModel model)
        {
            var comment = model.ArticleCommentModel;

            comment.Status = (byte)ArticleStatus.JustCreated;
            comment.Date   = DateTime.Now;
            if (ModelState.IsValid)
            {
                string strUrl = APIProvider.APIGenerator(controllerName + "/Comment", APIConstant.ACTION_INSERT);
                var    result = await InvokeTransaction(comment, strUrl);

                if (result > 0)
                {
                    return(RedirectToAction("Details", new { id = comment.ArticleId }));
                }
                else
                {
                    model = await SetArticleComment(comment);

                    return(View("Details", model));
                }
            }
            else
            {
                model = await SetArticleComment(comment);

                return(View("Details", 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));
        }