PostAsync(ViewModels.Applications.CreateViewModel viewModel)
        {
            var result =
                await PostAsync <ViewModels.Applications.CreateViewModel, Models.Application>(viewModel);

            return(result);
        }
        PostAsync(ViewModels.Applications.CreateViewModel viewModel)
        {
            try
            {
                // Check viewModel Validation!

                // Collection = Infrastructure.Utitily.CheckModel(viewModel)
                // Collection.Count -> 0 => No Error!
                // Loop Collection -> Result -> AddErrorMessage(item)

                var newEntity =
                    new Models.Application
                {
                    Name            = viewModel.Name,
                    Title           = viewModel.Title,
                    IsActive        = viewModel.IsActive,
                    Description     = viewModel.Description,
                    IsIPRestricted  = viewModel.IsIPRestricted,
                    IsUrlRestricted = viewModel.IsUrlRestricted,

                    //IsVerified = true,
                    //VerifierUserId = ...,
                    //VerifyDateTime = Models.Utility.Now,
                };

                //Logger.LogTrace(typeof(ApplicationsController), "یک شیء ایجاد می‌کنم");

                await UnitOfWork.ApplicationRepository.InsertAsync(newEntity);

                //Logger.LogTrace(typeof(ApplicationsController), "شیء را به ریپوزیتوری اضافه می‌کنم");

                await UnitOfWork.SaveAsync();

                //Logger.LogTrace(typeof(ApplicationsController), "یونیت آو ورک را ذخیره می‌کنم");

                return(Ok(value: newEntity));
            }
            catch (System.Exception ex)
            {
                //Logger.LogError(typeof(ApplicationsController), ex.Message);

                // "خطای ناشناخته‌ای صورت گرفته است لطفا با تیم پشتیبانی تماس حاصل فرمایید"

                return(Ok(value: null));
            }
        }
        PostAsync(ViewModels.Applications.CreateViewModel viewModel)
        {
            var newEntity =
                new Models.Application
            {
                Name            = viewModel.Name,
                Title           = viewModel.Title,
                IsActive        = viewModel.IsActive,
                Description     = viewModel.Description,
                IsIPRestricted  = viewModel.IsIPRestricted,
                IsUrlRestricted = viewModel.IsUrlRestricted,

                //IsVerified = true,
                //VerifierUserId = ...,
                //VerifyDateTime = Models.Utility.Now,
            };

            await UnitOfWork.ApplicationRepository.InsertAsync(newEntity);

            await UnitOfWork.SaveAsync();

            return(Ok(value: newEntity));
        }
Exemplo n.º 4
0
        public Microsoft.AspNetCore.Mvc.ActionResult <System.Collections.Generic.IEnumerable <Models.Application> > Post(ViewModels.Applications.CreateViewModel viewModel)
        {
            Models.Application application =
                new Models.Application
            {
                Name            = viewModel.Name,
                Title           = viewModel.Title,
                IsActive        = viewModel.IsActive,
                Description     = viewModel.Description,
                IsIPRestricted  = viewModel.IsIPRestricted,
                IsUrlRestricted = viewModel.IsUrlRestricted,

                //IsVerified = true,
                //VerifierUserId = ...,
                //VerifyDateTime = Models.Utility.Now,
            };

            MyDatabaseContext.Applications.Add(application);

            MyDatabaseContext.SaveChangesAsync();

            return(Ok(value: application));
        }