Esempio n. 1
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"));
            }
        }
        public async Task <ActionResult> ImportExcel()
        {
            var fileupload = Request.Files[0];

            if (fileupload != null)
            {
                var allowedExtensions = new[] { ".xls", ".xlsx", ".XLS", ".XLSX" };
                var extension         = Path.GetExtension(fileupload.FileName);
                if (allowedExtensions.Contains(extension))
                {
                    try
                    {
                        string filename = Path.GetFileName(fileupload.FileName);
                        string fullPath = Server.MapPath(ValueConstant.PATH_DOCS) + filename;
                        fileupload.SaveAs(fullPath);
                        var excel    = new ExcelQueryFactory(fullPath);
                        var schedule = from c in excel.Worksheet <ScheduleExcelViewModel>("Sheet1")
                                       select c;

                        controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                        string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_INSERT);
                        if (schedule != null)
                        {
                            foreach (var item in schedule)
                            {
                                string apiUrl = "User?email=" + item.UserId;
                                var    userid = await APIProvider.Authorize_Get <string>(_userSession.BearerToken, apiUrl, APIConstant.API_Resource_CORE, ARS.Get);

                                var model = new CreateScheduleViewModel()
                                {
                                    Title     = item.Title,
                                    Priority  = item.Priority,
                                    Detail    = item.Detail,
                                    IsAlarm   = item.IsAlarm,
                                    Start     = item.Start,
                                    End       = item.End,
                                    Color     = item.Color,
                                    IsExamine = item.IsExamine,
                                    UserId    = userid
                                };
                                var result = await APIProvider.Authorize_DynamicTransaction <CreateScheduleViewModel, int>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Insert);
                            }
                            TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS));
                            return(RedirectToAction("Index"));
                        }
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 3
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"));
            }
        }
        public async Task <ActionResult> Create(AdvertiseViewModel model, HttpPostedFileBase fileUpload)
        {
            try
            {
                var token = _userSession.BearerToken;

                if (fileUpload == null)
                {
                    ModelState.AddModelError("Resouce", "Vui lòng chọn video hoặc hình ảnh");
                }
                if (ModelState.IsValid)
                {
                    if (fileUpload != null)
                    {
                        string name = "";
                        if (fileUpload.ContentType.Contains("image"))
                        {
                            FileManagement.UploadImage(fileUpload, ValueConstant.IMAGE_ADVERTISE_PATH, ref name);
                            model.Type    = (Byte)ValueConstant.MEDIA_TYPE.IMAGE;
                            model.Resouce = name;
                        }
                        else
                        {
                            FileManagement.UploadFile(fileUpload, ValueConstant.IMAGE_ADVERTISE_PATH, ref name);
                            string pathVideo = Server.MapPath(name);
                            model.Type = (byte)ValueConstant.MEDIA_TYPE.VIDEO;

                            UploadVideo(fileUpload, pathVideo);
                            model.Resouce = name;
                        }
                    }

                    //Call API Provider
                    string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_INSERT);
                    var    result = await APIProvider.Authorize_DynamicTransaction <AdvertiseViewModel, bool>(model, token, strUrl, APIConstant.API_Resource_CMS, ARS.Insert);

                    if (result)
                    {
                        TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS));
                    }
                    else
                    {
                        TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                    }
                    return(RedirectToAction("Index"));
                }
                else
                {
                    var slider = new AdvertisesModel();
                    slider.lstAdvertiseViewModel = await APIProvider.Authorize_Get <List <AdvertiseViewModel> >(token, controllerName, APIConstant.API_Resource_CMS);

                    slider.AdvertiseViewModel = model;

                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                    return(View("Index", slider));
                }
            }
            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(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> 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 async Task <ActionResult> Edit(AdvertiseViewModel model, HttpPostedFileBase fileUpload)
        {
            var token = _userSession.BearerToken;

            if (fileUpload == null && String.IsNullOrEmpty(model.Resouce))
            {
                ModelState.AddModelError("Resouce", "Vui lòng chọn hình ảnh");
            }

            if (ModelState.IsValid)
            {
                if (fileUpload != null)
                {
                    string name = "";
                    if (fileUpload.ContentType.Contains("image"))
                    {
                        FileManagement.UploadImage(fileUpload, ValueConstant.IMAGE_ADVERTISE_PATH, ref name);
                        model.Type    = (byte)ValueConstant.MEDIA_TYPE.IMAGE;
                        model.Resouce = name;
                    }
                    else
                    {
                        FileManagement.UploadFile(fileUpload, ValueConstant.IMAGE_ADVERTISE_PATH, ref name);
                        string pathVideo = Server.MapPath(name);
                        model.Type = (byte)ValueConstant.MEDIA_TYPE.VIDEO;

                        string   pathThumbnail = Server.MapPath(ValueConstant.IMAGE_ADVERTISE_PATH);
                        var      ffMpeg        = new NReco.VideoConverter.FFMpegConverter();
                        string[] arrTemp       = fileUpload.FileName.Split('.');
                        string   fileName      = pathThumbnail + "/" + arrTemp[0] + ".jpg";
                        ffMpeg.GetVideoThumbnail(pathVideo, fileName, 10.0f);
                        model.Resouce = name.Replace(fileUpload.FileName, arrTemp[0] + ".jpg");
                    }
                }

                //Call API Provider
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_UPDATE);
                var    result = await APIProvider.Authorize_DynamicTransaction <AdvertiseViewModel, bool>(model, token, 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(model));
            }
        }
Esempio n. 8
0
        public async Task <ActionResult> UpdatePermission(List <RolePermissionViewModel> permissions)
        {
            if (permissions != null)
            {
                try
                {
                    // Filter permission with status is true
                    var model = new List <RolePermission>();
                    foreach (var item in permissions)
                    {
                        if (item.IsUsed)
                        {
                            var tmp = new RolePermission
                            {
                                PermissionId = item.Id,
                                RoleId       = item.RoleId
                            };
                            model.Add(tmp);
                        }
                    }

                    //Call API Provider
                    var token = _userSession.BearerToken;
                    var ret   = await APIProvider.Authorize_DynamicTransaction <List <RolePermission>, string>(model, token, "Role/UpdatePermission", APIConstant.API_Resource_Authorize);

                    if (ret == null)
                    {
                        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));
                    }
                }
                catch (Exception ex)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.FAIL));
                    Logger.LogError(ex);
                    throw ex.GetBaseException();
                }
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 9
0
        public async Task <ActionResult> Create(RoleViewModel model)
        {
            if (ModelState.IsValid)
            {
                //var strUrl = APIProvider.APIGenerator(controllerName + "/SetRole", APIConstant.ACTION_INSERT);
                var token  = _userSession.BearerToken;
                var result = await APIProvider.Authorize_DynamicTransaction <RoleViewModel, string>(model, token, "Role/SetRole", APIConstant.API_Resource_Authorize);

                if (result == null)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS));
                }
                else
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                    Exception ex = new Exception(result);
                    Logger.LogError(ex);
                }

                return(RedirectToAction("Index"));
            }
            else
            {
                var role = new RoleModel();
                if (TempData["Data"] == null)
                {
                    role.lstRoleViewModel = await APIProvider.Authorize_Get <List <RoleViewModel> >(_userSession.BearerToken, controllerName, APIConstant.API_Resource_Authorize);

                    TempData["Data"] = role.lstRoleViewModel;
                }
                else
                {
                    role.lstRoleViewModel = (List <RoleViewModel>)TempData["Data"];
                }

                role.RoleViewModel = model;

                //TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                return(View("Index", role));
            }
        }
Esempio n. 10
0
        public async Task <ActionResult> Edit(RoleViewModel model)
        {
            if (ModelState.IsValid)
            {
                //Call API Provider
                var token  = _userSession.BearerToken;
                var result = await APIProvider.Authorize_DynamicTransaction <RoleViewModel, bool>(model, token, "Role/UpdateRole", APIConstant.API_Resource_Authorize);

                if (Response.StatusCode == 200)
                {
                    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(ValueConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.FAIL));
                return(View(model));
            }
        }
Esempio n. 11
0
        public async Task <ActionResult> Delete(string id)
        {
            RoleViewModel model = new RoleViewModel();

            model.Id = id;
            try
            {
                var token = _userSession.BearerToken;
                //Call API Provider - data
                //var model = await APIProvider.Authorize_Get<RoleViewModel>(token, controllerName, $"Info?id={id}", null, APIConstant.API_Resource_Authorize);
                //Call API Provider - Transaction
                var result = await APIProvider.Authorize_DynamicTransaction <RoleViewModel, bool>(model, token, "Role/RemoveRole", APIConstant.API_Resource_Authorize, 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("Index"));
            }
        }
        public async Task <ActionResult> Create(GalleryViewModel model, HttpPostedFileBase fileUpload)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.Id = Guid.NewGuid().ToString();

                    if (fileUpload != null)
                    {
                        string imgName = "";
                        FileManagement.UploadImage(fileUpload, Path.Combine(ValueConstant.IMAGE_GALLERY_PATH, model.Id), ref imgName);
                        model.Img = imgName;
                    }

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

                    if (result)
                    {
                        TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS));
                    }
                    else
                    {
                        TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                    }
                    return(RedirectToAction("Index"));
                }
                else
                {
                    var department = new GalleryModel();
                    department.lstGallery = (List <GalleryViewModel>)TempData["Galleries"];

                    var departments = (List <DepartmentViewModel>)TempData["Departments"];
                    if (departments == null)
                    {
                        string strUrl = APIProvider.APIGenerator("Department", new List <string> {
                            "type"
                        }, true, "available");
                        departments = await APIProvider.Get <List <DepartmentViewModel> >(strUrl, APIConstant.API_Resource_CORE);
                    }
                    ViewBag.Departments = departments;


                    if (department.lstGallery == null)
                    {
                        department.lstGallery = ApplicationGenerator.GetObject <List <GalleryViewModel> >();
                    }
                    department.Gallery = model;

                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                    return(RedirectToAction("Index", department));
                }
            }
            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(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"));
            }
        }
        public async Task <ActionResult> Edit(GalleryViewModel model, HttpPostedFileBase fileUpload)
        {
            if (ModelState.IsValid)
            {
                if (fileUpload != null)
                {
                    string imgName = "";
                    FileManagement.UploadImage(fileUpload, Path.Combine(ValueConstant.IMAGE_GALLERY_PATH, model.Id), ref imgName);
                    model.Img = imgName;
                }
                //Call API Provider
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_UPDATE);
                var    result = await APIProvider.Authorize_DynamicTransaction <GalleryViewModel, 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
            {
                var departments = (List <DepartmentViewModel>)TempData["Departments"];
                if (departments == null)
                {
                    string strUrl = APIProvider.APIGenerator("Department", new List <string> {
                        "type"
                    }, true, "available");
                    departments = await APIProvider.Authorize_Get <List <DepartmentViewModel> >(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Get);
                }
                ViewBag.Departments = departments;

                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.FAIL));
                return(View(model));
            }
        }
Esempio n. 15
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));
            }
        }
Esempio n. 16
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());
            }
        }
Esempio n. 17
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"));
            }
        }
Esempio n. 18
0
        public async Task <ActionResult> Create(LanguageViewModel model, HttpPostedFileBase fileUpload)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (fileUpload != null)
                    {
                        model.Icon = FileManagement.ImageToByteArray(fileUpload);
                    }

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

                    if (result)
                    {
                        TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS));
                    }
                    else
                    {
                        TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                    }
                    return(RedirectToAction("Index"));
                }
                else
                {
                    var languages = new LanguagesModel();
                    if (TempData["Data"] != null)
                    {
                        languages.lstLanguageViewModel = (List <LanguageViewModel>)TempData["Data"];
                    }
                    else
                    {
                        languages.lstLanguageViewModel = await APIProvider.Authorize_Get <List <LanguageViewModel> >(_userSession.BearerToken, controllerName, APIConstant.API_Resource_CMS, ARS.Get);
                    }

                    languages.LanguageViewModel = model;

                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                    return(View("Index", languages));
                }
            }
            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;
            }
        }
Esempio n. 19
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));
            }
        }
        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> 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> ApplyAppointment(AppointmentLogEditModel model)
        {
            TimeSpan time = TimeSpan.Parse(model.TimeString);

            model.Time        = (int)time.TotalMinutes;
            model.PhysicianId = model.PhysicianIdTemp;
            if (model.PhysicianId == null)
            {
                model.PhysicianId = "";
            }
            ModelState["PhysicianId"].Errors.Clear();

            if (ModelState.IsValid)
            {
                model.Id     = Guid.NewGuid();
                model.Status = (byte)AppointmentStatus.Create;
                var result = await Save(model, APIConstant.ACTION_INSERT);

                if (result)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS_APPOINTMENT, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_APPOINMENT, ApplicationGenerator.TypeResult.SUCCESS_APPOINTMENT));
                    return(RedirectToAction("Make"));
                }
                else
                {
                    string search     = "";
                    var    doctorList = await GetListDoctor(search);

                    ViewBag.Doctors = doctorList;
                    return(PartialView("_Appointment", model));
                }
            }
            else
            {
                string search     = "";
                var    doctorList = await GetListDoctor(search);

                ViewBag.Doctors = doctorList;
                return(PartialView("_Appointment", model));
            }
        }
        public async Task <ActionResult> Create(ScheduleMultipleViewModel param)
        {
            if (ModelState.IsValid)
            {
                controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_INSERT);

                var model = param.CreateScheduleViewModel;
                model.Start = DateTime.Parse(model.StartDate + " " + model.StartTime);
                model.End   = DateTime.Parse(model.StartDate + " " + model.EndTime);
                model.Color = string.Empty;
                if (param.CreateScheduleViewModel.UserId == null)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.ERROR, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                    return(RedirectToAction("Index"));
                }

                var result = await APIProvider.Authorize_DynamicTransaction <CreateScheduleViewModel, int>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Insert);

                if (result > 0)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS));
                }
                else
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                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;
                return(View("Index", param));
            }
        }
        public async Task <ActionResult> Edit(SliderViewModel model, HttpPostedFileBase fileUpload)
        {
            if (fileUpload == null && String.IsNullOrEmpty(model.Image))
            {
                ModelState.AddModelError("Image", "Vui lòng chọn hình");
            }

            if (ModelState.IsValid)
            {
                if (fileUpload != null)
                {
                    model.Image = fileUpload.FileName;
                    string imgName = "";
                    FileManagement.UploadImage(fileUpload, ValueConstant.IMAGE_SLIDER_PATH, ref imgName);
                    model.Image = imgName;
                }

                //Call API Provider
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_UPDATE);
                var    result = await APIProvider.Authorize_DynamicTransaction <SliderViewModel, 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(model));
            }
        }
        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"));
            }
        }
        public async Task <ActionResult> Create(SliderViewModel model, HttpPostedFileBase fileUpload)
        {
            try
            {
                if (fileUpload == null)
                {
                    ModelState.AddModelError("Image", "Vui lòng chọn hình");
                }
                if (ModelState.IsValid)
                {
                    if (fileUpload != null)
                    {
                        model.Image = fileUpload.FileName;
                        string imgName = "";

                        int[] demiSize = LayoutGuide.GetDefaultSize(Image_ModuleName.Slider);
                        if (demiSize == null)
                        {
                            FileManagement.UploadImage(fileUpload, ValueConstant.IMAGE_SLIDER_PATH, ref imgName);
                        }
                        else
                        {
                            FileManagement.UploadImage(fileUpload, ValueConstant.IMAGE_SLIDER_PATH, ref imgName, demiSize[0], demiSize[1]);
                        }

                        model.Image = imgName;
                    }

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

                    if (result)
                    {
                        TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS));
                    }
                    else
                    {
                        TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                    }
                    return(RedirectToAction("Index"));
                }
                else
                {
                    var slider = new SliderModel();
                    if (TempData["Data"] == null)
                    {
                        slider.lstSliderViewModel = await APIProvider.Authorize_Get <List <SliderViewModel> >(_userSession.BearerToken, controllerName, APIConstant.API_Resource_CMS, ARS.Get);
                    }
                    else
                    {
                        slider.lstSliderViewModel = (List <SliderViewModel>)TempData["Data"];
                    }

                    if (slider.lstSliderViewModel == null)
                    {
                        slider.lstSliderViewModel = ApplicationGenerator.GetObject <List <SliderViewModel> >();
                    }
                    slider.SliderViewModel = model;

                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                    return(View("Index", slider));
                }
            }
            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;
            }
        }
Esempio n. 27
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));
            }
        }
Esempio n. 28
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));
            }
        }
Esempio n. 29
0
        public async Task <ActionResult> Create(OfferAdviseViewModel model)
        {
            model.PatientId = _userSession.UserId;
            model.Status    = (byte)EnumOfferAdviseStatus.New;
            if (ModelState.IsValid)
            {
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_INSERT);
                var    result = await APIProvider.Authorize_DynamicTransaction <OfferAdviseViewModel, int>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Insert);

                if (result > 0)
                {
                    ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS));
                }
                else
                {
                    ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                var offeradvise = new OfferAdviseModel();

                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);

                offeradvise.lstOfferAdviseViewModel = list;

                offeradvise.OfferAdviseViewModel = model;

                ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                return(View("Index", offeradvise));
            }
        }
Esempio n. 30
0
        public async Task <ActionResult> Create(PermissionViewModel model)
        {
            if (ModelState.IsValid)
            {
                //Call API Provider
                string strUrl = controllerName + ConstantDomain.SET_PERMISSION;
                var    token  = _userSession.BearerToken;

                var result = await APIProvider.Authorize_DynamicTransaction <PermissionViewModel, bool>(model, token, strUrl, APIConstant.API_Resource_Authorize);

                if (Response.StatusCode == 200)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS));
                }
                else
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                var permission = new PermissionModel();
                if (TempData["Data"] != null)
                {
                    permission.lstPermissionViewModel = (List <PermissionViewModel>)TempData["Data"];
                }
                else
                {
                    permission.lstPermissionViewModel = await APIProvider.Authorize_Get <List <PermissionViewModel> >(_userSession.BearerToken, controllerName, APIConstant.API_Resource_CORE, ARS.Insert);
                }

                permission.PermissionViewModel = model;

                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                return(View("Index", permission));
            }
        }