Пример #1
0
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            RequiresAuthorization(AuthorizationStrings.CreateGlobal);
            var bootEntry = new BootEntryEntity
            {
                Name        = txtName.Text,
                Description = txtDescription.Text,
                Content     = txtContents.Text,
                Type        = ddlType.Text,
                Order       = txtOrder.Text,
                Active      = chkActive.Checked ? 1 : 0,
                Default     = chkDefault.Checked ? 1 : 0
            };

            var result = Call.BootEntryApi.Post(bootEntry);

            if (!result.Success)
            {
                EndUserMessage = result.ErrorMessage;
            }
            else
            {
                EndUserMessage = "Successfully Added Boot Menu Entry";
                Response.Redirect("~/views/admin/bootmenu/editentry.aspx?&entryid=" + result.Id);
            }
        }
Пример #2
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     RequiresAuthorization(AuthorizationStrings.ReadAdmin);
     BootEntry = !string.IsNullOrEmpty(Request["entryid"])
         ? Call.BootEntryApi.Get(Convert.ToInt32(Request.QueryString["entryid"]))
         : null;
 }
Пример #3
0
        public ActionResultDTO Put(int id, BootEntryEntity bootEntry)
        {
            bootEntry.Id = id;
            var result = _bootEntryServices.UpdateBootEntry(bootEntry);

            if (result.Id == 0)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound, result));
            }
            return(result);
        }
Пример #4
0
        public ActionResultDTO Put(int id, BootEntryEntity tObject)
        {
            Request.Method = Method.PUT;
            Request.AddJsonBody(tObject);
            Request.Resource = string.Format("api/{0}/Put/{1}", Resource, id);
            var response = _apiRequest.Execute <ActionResultDTO>(Request);

            if (response.Id == 0)
            {
                response.Success = false;
            }
            return(response);
        }
Пример #5
0
        public ActionResultDTO AddBootEntry(BootEntryEntity bootEntry)
        {
            var validationResult = ValidateEntry(bootEntry, true);
            var actionResult     = new ActionResultDTO();

            if (validationResult.Success)
            {
                _uow.BootEntryRepository.Insert(bootEntry);
                _uow.Save();

                actionResult.Success = true;
                actionResult.Id      = bootEntry.Id;
            }

            return(actionResult);
        }
Пример #6
0
        private ValidationResultDTO ValidateEntry(BootEntryEntity bootEntry, bool isNewEntry)
        {
            var validationResult = new ValidationResultDTO {
                Success = true
            };

            if (string.IsNullOrEmpty(bootEntry.Name))
            {
                validationResult.Success      = false;
                validationResult.ErrorMessage = "Boot Entry Name Is Not Valid";
                return(validationResult);
            }

            if (isNewEntry)
            {
                using (var uow = new UnitOfWork())
                {
                    if (uow.BootEntryRepository.Exists(h => h.Name == bootEntry.Name))
                    {
                        validationResult.Success      = false;
                        validationResult.ErrorMessage = "This Boot Entry Already Exists";
                        return(validationResult);
                    }
                }
            }
            else
            {
                using (var uow = new UnitOfWork())
                {
                    var originalTemplate = uow.BootEntryRepository.GetById(bootEntry.Id);
                    if (originalTemplate.Name != bootEntry.Name)
                    {
                        if (uow.BootEntryRepository.Exists(h => h.Name == bootEntry.Name))
                        {
                            validationResult.Success      = false;
                            validationResult.ErrorMessage = "This Boot Template Already Exists";
                            return(validationResult);
                        }
                    }
                }
            }

            return(validationResult);
        }
Пример #7
0
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            RequiresAuthorization(AuthorizationStrings.UpdateGlobal);
            var bootEntry = new BootEntryEntity
            {
                Id          = BootEntry.Id,
                Name        = txtName.Text,
                Description = txtDescription.Text,
                Content     = txtContents.Text,
                Type        = ddlType.Text,
                Order       = txtOrder.Text,
                Active      = chkActive.Checked ? 1 : 0,
                Default     = chkDefault.Checked ? 1 : 0
            };

            var result = Call.BootEntryApi.Put(bootEntry.Id, bootEntry);

            EndUserMessage = !result.Success ? result.ErrorMessage : "Successfully Updated Boot Menu Entry";
        }
Пример #8
0
        public ActionResultDTO UpdateBootEntry(BootEntryEntity bootEntry)
        {
            var validationResult = ValidateEntry(bootEntry, false);
            var actionResult     = new ActionResultDTO();

            if (validationResult.Success)
            {
                _uow.BootEntryRepository.Update(bootEntry, bootEntry.Id);

                _uow.Save();
                actionResult.Success = true;
                actionResult.Id      = bootEntry.Id;
            }
            else
            {
                actionResult.ErrorMessage = validationResult.ErrorMessage;
            }

            return(actionResult);
        }
Пример #9
0
 public ActionResultDTO Post(BootEntryEntity bootEntry)
 {
     return(_bootEntryServices.AddBootEntry(bootEntry));
 }