예제 #1
0
        public IActionResult Edit(LoanMan model)
        {
            AlertBack alert = new AlertBack();

            try
            {
                if (ModelState.IsValid)
                {
                    _loanManService.Update(model);
                    alert.Status  = "success";
                    alert.Message = "Register Successfully";
                }
                else
                {
                    alert.Status = "warning";
                    foreach (var key in this.ViewData.ModelState.Keys)
                    {
                        foreach (var err in this.ViewData.ModelState[key].Errors)
                        {
                            alert.Message += err.ErrorMessage + "<br/>";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                alert.Status  = "error";
                alert.Message = ex.Message;
            }

            return(Json(alert));
        }
        public IActionResult AddMenuPermission(int menuId, int roleId, Nullable <int> sortOrder, Nullable <int> user)
        {
            AlertBack alert = new AlertBack();

            try
            {
                MenuPermission menu = new MenuPermission
                {
                    IsCreate  = true,
                    IsDelete  = true,
                    IsRead    = true,
                    IsUpdate  = true,
                    IsActive  = true,
                    MenuId    = menuId,
                    RoleId    = roleId,
                    UserId    = user,
                    SortOrder = sortOrder
                };
                _menuPermissionService.Insert(menu);
                alert.Status  = "success";
                alert.Message = menu.Id.ToString();
            }
            catch (Exception ex)
            {
                alert.Status  = "error";
                alert.Message = ex.Message;
            }

            return(Json(alert));
        }
        public AlertBack DeleteLedgerAccount([FromBody] LedgerAccount model, int id = 0)
        {
            AlertBack alert = new AlertBack();

            ledgerAccountService.Delete(model);
            alert.status  = "success";
            alert.message = "Register Successfully";
            return(alert);
        }
        public AlertBack DeleteUser([FromBody] User model, int id = 0)
        {
            AlertBack alert = new AlertBack();

            userService.Delete(model);
            alert.status  = "success";
            alert.message = "Register Successfully";
            return(alert);
        }
예제 #5
0
        public AlertBack DeleteMenuPermission([FromBody] MenuPermission model, int id = 0)
        {
            AlertBack alert = new AlertBack();

            menuPermissionService.Delete(model);
            alert.status  = "success";
            alert.message = "Register Successfully";
            return(alert);
        }
        public AlertBack DeleteAppSetting([FromBody] AppSetting model, int id = 0)
        {
            AlertBack alert = new AlertBack();

            appSettingService.Delete(model);
            alert.status  = "success";
            alert.message = "Register Successfully";
            return(alert);
        }
        public AlertBack DeleteAccountTransaction([FromBody] AccountTransaction model, int id = 0)
        {
            AlertBack alert = new AlertBack();

            accountTransactionService.Delete(model);
            alert.status  = "success";
            alert.message = "Register Successfully";
            return(alert);
        }
        public IActionResult Delete(int id)
        {
            AlertBack alert = new AlertBack();

            MenuPermission ObjMenuPermission = _menuPermissionService.Get(id);

            _menuPermissionService.Delete(ObjMenuPermission);
            alert.Status  = "success";
            alert.Message = "Register Successfully";

            return(Json(alert));
        }
        public IActionResult Create([FromForm] AppSetting model, IFormFile logo, string logo11, IFormFile loginPageBackground, string loginPageBackground12)
        {
            AlertBack alert = new AlertBack();

            try
            {
                if (ModelState.IsValid)
                {
                    if (logo != null)
                    {
                        ModelState.Clear();
                        model.Logo = Env.GetUploadedFilePath(logo).Result;
                    }
                    else
                    {
                        model.Logo = logo11;
                    }
                    if (loginPageBackground != null)
                    {
                        ModelState.Clear();
                        model.LoginPageBackground = Env.GetUploadedFilePath(loginPageBackground).Result;
                    }
                    else
                    {
                        model.LoginPageBackground = loginPageBackground12;
                    }

                    _appSettingService.Insert(model);
                    alert.Status  = "success";
                    alert.Message = "Register Successfully";
                }
                else
                {
                    alert.Status = "warning";
                    foreach (var key in this.ViewData.ModelState.Keys)
                    {
                        foreach (var err in this.ViewData.ModelState[key].Errors)
                        {
                            alert.Message += err.ErrorMessage + "<br/>";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                alert.Status  = "error";
                alert.Message = ex.Message;
            }

            return(Json(alert));
        }
        public AlertBack PostUser([FromForm] User model, IFormFile profilePicture, string profilePicture7)
        {
            AlertBack alert = new AlertBack();

            if (ModelState.IsValid)
            {
                if (profilePicture != null)
                {
                    var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/uploads", profilePicture.FileName);

                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        profilePicture.CopyTo(stream);
                    }
                    ModelState.Clear();
                    model.ProfilePicture = profilePicture.FileName;
                }
                else
                {
                    model.ProfilePicture = profilePicture7;
                }

                userService.Insert(model);
                alert.status  = "success";
                alert.message = "Register Successfully";
                return(alert);
            }
            else
            {
                alert.status = "warning";
                foreach (var key in this.ModelState.Keys)
                {
                    foreach (var err in this.ModelState[key].Errors)
                    {
                        alert.message += err.ErrorMessage + "<br/>";
                    }
                }
                return(alert);
            }
        }
        public AlertBack PutAppSetting([FromForm] AppSetting model, IFormFile logo, string logo11, int id = 0)
        {
            AlertBack alert = new AlertBack();

            if (ModelState.IsValid)
            {
                if (logo != null)
                {
                    var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/uploads", logo.FileName);

                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        logo.CopyTo(stream);
                    }
                    ModelState.Clear();
                    model.Logo = logo.FileName;
                }
                else
                {
                    model.Logo = logo11;
                }

                appSettingService.Update(model);
                alert.status  = "success";
                alert.message = "Register Successfully";
                return(alert);
            }
            else
            {
                alert.status = "warning";
                foreach (var key in this.ModelState.Keys)
                {
                    foreach (var err in this.ModelState[key].Errors)
                    {
                        alert.message += err.ErrorMessage + "<br/>";
                    }
                }
                return(alert);
            }
        }
        public AlertBack PutLedgerAccount([FromForm] LedgerAccount model, int id = 0)
        {
            AlertBack alert = new AlertBack();

            if (ModelState.IsValid)
            {
                ledgerAccountService.Update(model);
                alert.status  = "success";
                alert.message = "Register Successfully";
                return(alert);
            }
            else
            {
                alert.status = "warning";
                foreach (var key in this.ModelState.Keys)
                {
                    foreach (var err in this.ModelState[key].Errors)
                    {
                        alert.message += err.ErrorMessage + "<br/>";
                    }
                }
                return(alert);
            }
        }
예제 #13
0
        public AlertBack PostMenuPermission([FromForm] MenuPermission model)
        {
            AlertBack alert = new AlertBack();

            if (ModelState.IsValid)
            {
                menuPermissionService.Insert(model);
                alert.status  = "success";
                alert.message = "Register Successfully";
                return(alert);
            }
            else
            {
                alert.status = "warning";
                foreach (var key in this.ModelState.Keys)
                {
                    foreach (var err in this.ModelState[key].Errors)
                    {
                        alert.message += err.ErrorMessage + "<br/>";
                    }
                }
                return(alert);
            }
        }
        public IActionResult Update(int id, string fieldName, string value)
        {
            AlertBack      alert = new AlertBack();
            MenuPermission model = _menuPermissionService.Get(id);

            if (fieldName == "SortOrder")
            {
                model.SortOrder = int.Parse(value);
            }
            else if (fieldName == "IsCreate")
            {
                model.IsCreate = bool.Parse(value);
            }
            else if (fieldName == "IsRead")
            {
                model.IsRead = bool.Parse(value);
            }
            else if (fieldName == "IsUpdate")
            {
                model.IsUpdate = bool.Parse(value);
            }
            else if (fieldName == "IsDelete")
            {
                model.IsDelete = bool.Parse(value);
            }
            else if (fieldName == "IsActive")
            {
                model.IsActive = bool.Parse(value);
            }

            _menuPermissionService.Update(model);
            alert.Status  = "success";
            alert.Message = "Updated Successfully";

            return(Json(alert));
        }