Exemple #1
0
        public IActionResult Get(int id)
        {
            var repo = this.Storage.GetRepository <IGradingTitleRepository>();

            GradingTitle grad = repo.WithKey(id);

            if (grad == null)
            {
                return(this.NotFound(new { success = false }));
            }

            return(Ok(new { success = true, data = grad }));
        }
Exemple #2
0
        public IActionResult Post(GradingTitleCreateViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                GradingTitle grad = model.ToGradingEntity();
                var          repo = this.Storage.GetRepository <IGradingTitleRepository>();

                repo.Create(grad, GetCurrentUserName());
                this.Storage.Save();

                return(Ok(new { success = true, data = grad }));
            }

            return(BadRequest(new { success = false }));
        }
Exemple #3
0
        public IActionResult Delete(int id)
        {
            var repo = this.Storage.GetRepository <IGradingTitleRepository>();

            GradingTitle grad = repo.WithKey(id);

            if (grad == null)
            {
                return(this.NotFound(new { success = false }));
            }

            repo.Delete(grad, GetCurrentUserName());
            this.Storage.Save();

            return(Ok(new { success = "Data berhasil dihapus" }));
        }
Exemple #4
0
        public IActionResult Put(int id, GradingTitleUpdateViewModel model)
        {
            var repo = this.Storage.GetRepository <IGradingTitleRepository>();

            GradingTitle grad = repo.WithKey(id);

            if (grad == null)
            {
                return(this.NotFound(new { success = false }));
            }

            if (this.ModelState.IsValid)
            {
                model.ToGradingEntity(grad);
                repo.Edit(grad, GetCurrentUserName());
                this.Storage.Save();

                return(Ok(new { success = "Data berhasil diperbaharui" }));
            }

            return(BadRequest(new { success = false }));
        }