Пример #1
0
        public async Task <ActionResult> Create(AddCatalogViewModel request)
        {
            if (!ModelState.IsValid)
            {
                Alert($"Invalid Request.", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
            try
            {
                var catalogRequest = new AddCatalogRequest
                {
                    Name          = request.Name,
                    Description   = request.Description,
                    EffectiveDate = request.EffectiveDate,
                    EndDate       = request.EndDate,
                    EntityId      = request.EntityId,
                    Published     = request.Published
                };

                var result = await _catalogService.Create(catalogRequest);

                if (!result.Success)
                {
                    Alert($"{result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View());
                }
                Alert($"Catalog Created Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                Alert($"Error! {ex.Message}.", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
        }
Пример #2
0
        public Catalog Create(Catalog catalog)
        {
            var retVal = _catalogService.Create(catalog);

            ClearCache();
            return(retVal);
        }
Пример #3
0
        public IHttpActionResult Create(webModel.Catalog catalog)
        {
            var newCatalog = _catalogService.Create(catalog.ToModuleModel());
            var retVal     = newCatalog.ToWebModel();

            //Need for UI permission checks
            retVal.SecurityScopes = GetObjectPermissionScopeStrings(newCatalog);
            return(Ok(retVal));
        }
Пример #4
0
 public ActionResult Create(CatalogModel catalog)
 {
     if (ModelState.IsValid)
     {
         _service.Create(_mapper.Map <CatalogBL>(catalog));
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Пример #5
0
        public ActionResult Create(Dto.ProductCreate productCreate)
        {
            var validationResults = catalogService.Create(productCreate);

            if (validationResults.Count() > 0)
            {
                return(BadRequest(validationResults));
            }

            return(Ok());
        }
Пример #6
0
        public async Task <IActionResult> Create(AlbumDTO album)
        {
            if (ModelState.IsValid)
            {
                await _catalogService.Create(album);

                return(RedirectToAction("Index"));
            }

            GetArtistsAndGenres(album);
            return(View(album));
        }
 public IHttpActionResult Create(webModel.Catalog catalog)
 {
     if ((_permissionService.UserHasAnyPermission(RequestContext.Principal.Identity.Name, PredefinedPermissions.CatalogsManage) && !catalog.Virtual) ||
         (_permissionService.UserHasAnyPermission(RequestContext.Principal.Identity.Name, PredefinedPermissions.VirtualCatalogsManage) && catalog.Virtual))
     {
         var retVal = _catalogService.Create(catalog.ToModuleModel());
         return(Ok(retVal.ToWebModel()));
     }
     else
     {
         throw new UnauthorizedAccessException();
     }
 }
Пример #8
0
        private void UpdateCatalogs(ICollection <Catalog> original, ICollection <Catalog> backup)
        {
            var toUpdate = new List <Catalog>();

            backup.CompareTo(original, EqualityComparer <Catalog> .Default, (state, x, y) =>
            {
                switch (state)
                {
                case EntryState.Modified:
                    toUpdate.Add(x);
                    break;

                case EntryState.Added:
                    _catalogService.Create(x);
                    break;
                }
            });
            _catalogService.Update(toUpdate.ToArray());
        }
Пример #9
0
        public async Task <IActionResult> Create([FromBody] CatalogItem catalogItem)
        {
            await _catalogService.Create(catalogItem);

            return(RedirectToAction(nameof(Index)));
        }
Пример #10
0
 public IHttpActionResult Create(CatalogCreate catalog)
 {
     _catalogService.Create(catalog);
     return(Ok());
 }