コード例 #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));
        }
コード例 #7
0
 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
ファイル: CatalogController.cs プロジェクト: zsra/energy
        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());
 }