Exemplo n.º 1
0
        private async void SaveEditedTag()
        {
            if (SelectedTag != null)
            {
                var numberOfEqualTags = TagCopy.Select(x => x).Where(t => t.Name.ToUpper().Equals(SelectedTag.Name.ToUpper())).ToArray().Count();
                if (numberOfEqualTags > 0)
                {
                    await m_popupDialog.Dialog.ShowMessageAsync(this, "Kan ikke endre navn på tag", $"Det eksisterer allerede en tag som heter {SelectedTag.Name}, velg et annet navn eller bruk den du allerede har");

                    m_viewDisabler.Disable("Laster...", RefreshTag());
                    return;
                }
                await m_foodFacade.UpdateTag(SelectedTag);

                m_viewDisabler.Disable("Laster...", RefreshTag());
            }
        }
Exemplo n.º 2
0
        public Tag Post(TagCopy request)
        {
            Tag ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityTag.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pName = entity.Name;
                    if (!DocTools.IsNullOrEmpty(pName))
                    {
                        pName += " (Copy)";
                    }
                    var pScopes = entity.Scopes.ToList();
                    var pURI    = entity.URI;
                    if (!DocTools.IsNullOrEmpty(pURI))
                    {
                        pURI += " (Copy)";
                    }
                    var copy = new DocEntityTag(ssn)
                    {
                        Hash   = Guid.NewGuid()
                        , Name = pName
                        , URI  = pURI
                    };
                    foreach (var item in pScopes)
                    {
                        entity.Scopes.Add(item);
                    }

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }