Пример #1
0
        public ResultWithData <CategoryModel> Add(AddModel addModel)
        {
            IReturn @IReturn = ApplicationRegistry.Category.Add(addModel.Name, addModel.Sort, addModel.RestaurantId);
            ResultWithData <CategoryModel> result = @IReturn.Result(SystemHelper.GetSystemIdAndVersion(this.Request));

            return(result);
        }
Пример #2
0
        public ActionResult SiteAdd()
        {
            AddModel model = new AddModel {
            };

            return(View(model));
        }
Пример #3
0
 private void addModel(object sender, AddModel e)
 {
     SendMessages = false;
     e.Model.Id   = e.Id;
     Models.Add(e.Model, e.Id, false);
     SendMessages = true;
 }
Пример #4
0
        public async Task OnPost_ValidModel_NearbyFacilities_ReturnsConfirmationPage()
        {
            var nearbyFacilities = new List <FacilityMapSummaryDto>()
            {
                new FacilityMapSummaryDto()
                {
                    Id             = Guid.Empty,
                    FacilityNumber = "test",
                }
            };

            var mockRepo = new Mock <IFacilityRepository>();

            mockRepo.Setup(l => l.GetFacilityListAsync(It.IsAny <FacilityMapSpec>()))
            .ReturnsAsync(nearbyFacilities);

            var mockSelectListHelper = new Mock <ISelectListHelper>();
            var pageModel            = new AddModel(mockRepo.Object, mockSelectListHelper.Object)
            {
                Facility = new FacilityCreateDto {
                    State = "Georgia"
                }
            };

            var result = await pageModel.OnPostAsync().ConfigureAwait(false);

            result.Should().BeOfType <PageResult>();
            pageModel.ModelState.IsValid.ShouldBeTrue();
            pageModel.ConfirmFacility.ShouldBeTrue();
            pageModel.NearbyFacilities.Should().BeEquivalentTo(nearbyFacilities);
        }
Пример #5
0
        public async Task OnPost_ValidModel_NoNearbyFacilities_ReturnsDetailsPage()
        {
            // ReSharper disable once CollectionNeverUpdated.Local
            var nearbyFacilities = new List <FacilityMapSummaryDto>();
            var newId            = Guid.NewGuid();
            var mockRepo         = new Mock <IFacilityRepository>();

            mockRepo.Setup(l => l.CreateFacilityAsync(It.IsAny <FacilityCreateDto>()))
            .ReturnsAsync(newId);
            mockRepo.Setup(l => l.GetFacilityListAsync(It.IsAny <FacilityMapSpec>()))
            .ReturnsAsync(nearbyFacilities);

            var mockSelectListHelper = new Mock <ISelectListHelper>();
            var pageModel            = new AddModel(mockRepo.Object, mockSelectListHelper.Object)
            {
                Facility = new FacilityCreateDto {
                    State = "Georgia"
                }
            };

            var result = await pageModel.OnPostAsync().ConfigureAwait(false);

            result.Should().BeOfType <RedirectToPageResult>();
            pageModel.ModelState.IsValid.ShouldBeTrue();
            pageModel.ConfirmFacility.ShouldBeFalse();
            pageModel.NearbyFacilities.Should().BeEquivalentTo(nearbyFacilities);
            ((RedirectToPageResult)result).PageName.Should().Be("./Details");
            ((RedirectToPageResult)result).RouteValues["id"].Should().Be(newId);
        }
Пример #6
0
        public async Task <ActionResult> SiteAdd_Partial(AddModel model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView(model));
            }

            SiteDefinition currentSite = Manager.CurrentSite;

            SiteDefinition newSite = model.GetData();
            await newSite.AddNewAsync();

            Manager.CurrentSite = newSite;
            try {
                PackagesDataProvider packagesDP = new PackagesDataProvider();
                await packagesDP.InitNewAsync(true);
            } catch (Exception) {
                throw;
            } finally {
                Manager.CurrentSite = currentSite;
            }

            string nextPage = Manager.CurrentSite.MakeUrl(RealDomain: Manager.CurrentSite.SiteDomain);

            Manager.RestartSite();

            return(FormProcessed(model, this.__ResStr("okSaved", "New site \"{0}\" created - Click OK to populate the new site with the current site template.(+nl)(+nl)IMPORTANT: This site is not accessible by its Url until the domain \"{0}\" is defined in IIS and in the hosts file.", newSite.SiteDomain),
                                 NextPage: nextPage));
        }
Пример #7
0
        public ActionResult CategoryAdd()
        {
            AddModel model = new AddModel {
            };

            return(View(model));
        }
Пример #8
0
        public IActionResult Add([FromForm] AddModel add)
        {
            Console.WriteLine(" 输出:  " + add.Name);
            _bus.Send(new CreateInventoryItem(Guid.NewGuid(), add.Name));

            return(RedirectToAction("Index"));
        }
Пример #9
0
        public async Task <ActionResult> CommentAdd(int?blogEntry)
        {
            int entryNum = blogEntry ?? 0;
            int blogCategory;

            using (BlogEntryDataProvider entryDP = new BlogEntryDataProvider()) {
                BlogEntry data = null;
                if (entryNum != 0)
                {
                    data = await entryDP.GetItemAsync(entryNum);
                }
                if (data == null)
                {
                    return(new EmptyResult());
                }
                blogCategory = data.CategoryIdentity;
                if (!data.OpenForComments)
                {
                    if (data.Comments == 0)
                    {
                        return(new EmptyResult());
                    }
                }
            }
            AddModel model = new AddModel {
                CategoryIdentity = blogCategory,
                EntryIdentity    = entryNum,
                Captcha          = new RecaptchaV2Data(),
            };
            await model.UpdateDataAsync();

            return(View(model));
        }
Пример #10
0
        public async Task OnPost_ValidModel_ReturnsDetailsPage()
        {
            var mockRepo = new Mock <ICabinetRepository>();

            mockRepo.Setup(l => l.CabinetNameExistsAsync(It.IsAny <string>(), It.IsAny <Guid?>()))
            .ReturnsAsync(false);
            mockRepo.Setup(l => l.CreateCabinetAsync(It.IsAny <CabinetEditDto>()));

            var newCabinet = new CabinetEditDto()
            {
                Name           = "New Cabinet",
                FirstFileLabel = "999-9999",
            };

            var pageModel = new AddModel(mockRepo.Object)
            {
                NewCabinet = newCabinet
            };

            var result = await pageModel.OnPostAsync().ConfigureAwait(false);

            result.Should().BeOfType <RedirectToPageResult>();
            pageModel.ModelState.IsValid.ShouldBeTrue();
            ((RedirectToPageResult)result).PageName.Should().Be("./Details");
            ((RedirectToPageResult)result).RouteValues["id"].Should().Be(newCabinet.Name);
        }
Пример #11
0
        public ActionResult AddOrder(AddModel model)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckObjectArgument <AddModel>("model", model);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                model.PostValidate(ref validate);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                this.saleOrderService.Insert(model.Date, model.Item, model.Unit, model.Price, model.Quantity, model.ActualAmount, model.NeedExpress ? Constant.COMMON_Y : Constant.COMMON_N, model.Remark, model.AddressId, this.Session["Mobile"].ToString());
                result.Data   = "/SaleOrder/Index";
                result.Result = true;
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
            }
            return(Json(result));
        }
Пример #12
0
        public async Task <ActionResult> FeedbackAdd_Partial(AddModel model)
        {
            FeedbackConfigData config = await FeedbackConfigDataProvider.GetConfigAsync();

            model.RequireName  = config.RequireName;
            model.RequireEmail = config.RequireEmail;
            model.ShowCaptcha  = config.Captcha;

            if (!ModelState.IsValid)
            {
                return(PartialView(model));
            }

            using (FeedbackDataProvider dataProvider = new FeedbackDataProvider()) {
                if (!await dataProvider.AddItemAsync(model.GetData()))
                {
                    throw new InternalError("Feedback couldn't be sent");
                }

                Emails emails = new Emails(Manager);
                await emails.SendFeedbackAsync(config.Email, model.Email, model.Subject, model.Message, model.Name, config.BccEmails?Manager.CurrentSite.AdminEmail : null);

                return(FormProcessed(model, this.__ResStr("okSaved", "Your message has been sent!"), NextPage: Manager.ReturnToUrl));
            }
        }
Пример #13
0
        public ActionResult Add(AddModel model)
        {
            decimal Sum = model.FirstNumber + model.SecondNumber;

            model.Sum = Sum;
            return(View("Index", model));
        }
Пример #14
0
        public async Task OnPostConfirm_ValidModel_ReturnsDetailsPage()
        {
            var newId    = Guid.NewGuid();
            var mockRepo = new Mock <IFacilityRepository>();

            mockRepo.Setup(l => l.CreateFacilityAsync(It.IsAny <FacilityCreateDto>()))
            .ReturnsAsync(newId)
            .Verifiable();
            mockRepo.Setup(l => l.FileLabelExists(It.IsAny <string>()))
            .ReturnsAsync(true);

            var mockSelectListHelper = new Mock <ISelectListHelper>();
            var pageModel            = new AddModel(mockRepo.Object, mockSelectListHelper.Object)
            {
                Facility = new FacilityCreateDto {
                    State = "Georgia"
                }
            };

            var result = await pageModel.OnPostConfirmAsync().ConfigureAwait(false);

            result.Should().BeOfType <RedirectToPageResult>();
            pageModel.ModelState.IsValid.ShouldBeTrue();
            pageModel.ConfirmFacility.ShouldBeFalse();
            ((RedirectToPageResult)result).PageName.Should().Be("./Details");
            ((RedirectToPageResult)result).RouteValues["id"].Should().Be(newId);
        }
Пример #15
0
 public ActionResult AddEmploye(AddModel model)
 {
     try
     {
         var department = _departmentsService.GetById(model.Department);
         var language   = _languagesService.GetById(model.Language);
         var data       = new EmployesDomain()
         {
             LastName   = model.LastName,
             FirstName  = model.FirstName,
             Age        = Int32.Parse(model.Age),
             IsDeleted  = false,
             Department = department,
             Gender     = (EGender)model.Gender,
             Experience = new ExperienceDomain()
             {
                 LanguageId = model.Language
             }
         };
         _employesService.AddEmploye(data);
         return(Json(new { redirectUrl = Url.Action("Index", "Home") }));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #16
0
 public ActionResult Add(AddModel model)
 {
     if (model.File != null)
     {
         string pathFile = "/Files/" + User.Identity.Name + "/";
         string pathIco  = "/Files/Ico/" + User.Identity.Name + "/";
         if (!Directory.Exists(Server.MapPath(pathFile)))
         {
             Directory.CreateDirectory(Server.MapPath(pathFile));
         }
         if (!Directory.Exists(Server.MapPath(pathIco)))
         {
             Directory.CreateDirectory(Server.MapPath(pathIco));
         }
         string filename = Path.GetFileName(model.File.FileName);
         model.File.SaveAs(Server.MapPath(pathFile + filename));
         int    author        = _authProvider.SearchUser(User.Identity.Name);
         string path          = pathFile + filename;
         Icon   extractedIcon = Icon.ExtractAssociatedIcon(Server.MapPath(pathFile + filename));
         string icostr        = filename;
         string v             = Path.GetExtension(filename);
         icostr = icostr.Replace(v, "") + ".jpg";
         Bitmap bitmap = extractedIcon.ToBitmap();
         bitmap.Save(Server.MapPath(pathIco + icostr));
         icostr = "/Files/Ico/" + User.Identity.Name + "/" + icostr;
         _noteRepositoty.Add(model.Name, author, icostr, path, model.Published, model.Text, model.Tag);
     }
     return(RedirectToAction("MyIndex"));
 }
Пример #17
0
        public ActionResult Index()
        {
            var names = _employesService.GetAllEmployes().Select(domain => domain.FirstName).ToList();

            var departments = _departmentsService.GetAll().Select(domain => new DepartmentModel()
            {
                DepartmentId   = domain.DepartmentId,
                DepartmentName = domain.Name
            }).ToList();

            var languages = _languagesService.GetAll().Select(domain => new LanguagesModel()
            {
                LanguageId = domain.LanguageId,
                Name       = domain.Name
            }).ToList();

            var model = new AddModel()
            {
                Departments = departments,
                Languages   = languages,
                Names       = names
            };

            return(View(model));
        }
Пример #18
0
        public async Task <ActionResult> SiteAnnouncement_Partial(AddModel model)
        {
            model.UpdateData();
            if (!ModelState.IsValid)
            {
                return(PartialView(model));
            }

            if (model.TestMode)
            {
                return(FormProcessed(model, model.Message, model.Title, OnClose: OnCloseEnum.UpdateInPlace, OnPopupClose: OnPopupCloseEnum.UpdateInPlace, PopupOptions: "{encoded:true, canClose: true, autoClose: 0}"));
            }
            else
            {
                using (SiteAnnouncementDataProvider siteAnnounceDP = new SiteAnnouncementDataProvider()) {
                    await YetaWF_Messenger_SiteAnnouncementsHub.SendMessageAsync(model.Message, model.Title);

                    if (await siteAnnounceDP.IsInstalledAsync())
                    {
                        if (!await siteAnnounceDP.AddItemAsync(model.GetData()))
                        {
                            throw new Error(this.__ResStr("noLog", "Message sent. New site announcement log record couldn't be added"));
                        }
                    }
                }
                return(FormProcessed(model));
            }
        }
Пример #19
0
        public async Task <ActionResult> CommentAdd_Partial(AddModel model)
        {
            await model.UpdateDataAsync();

            using (BlogEntryDataProvider entryDP = new BlogEntryDataProvider()) {
                BlogEntry blogEntry = await entryDP.GetItemAsync(model.EntryIdentity);

                if (blogEntry == null)
                {
                    throw new Error(this.__ResStr("notFound", "Blog entry with id {0} not found."), model.EntryIdentity);
                }
                if (!blogEntry.OpenForComments)
                {
                    throw new InternalError("Can't add comments to this blog entry");
                }
                if (!ModelState.IsValid)
                {
                    return(PartialView(model));
                }
                using (BlogCommentDataProvider blogCommentDP = new BlogCommentDataProvider(model.EntryIdentity)) {
                    BlogComment blogComment = model.GetData();
                    if (!await blogCommentDP.AddItemAsync(blogComment))
                    {
                        throw new Error(this.__ResStr("alreadyExists", "An error occurred adding this new comment"));
                    }

                    // send notification email
                    BlogConfigData config = await BlogConfigDataProvider.GetConfigAsync();

                    if (config.NotifyNewComment)
                    {
                        SendEmail sendEmail = new SendEmail();
                        object    parms     = new {
                            Description = !blogComment.Approved ? this.__ResStr("needApproval", "This comment requires your approval.") : this.__ResStr("autoApproval", "This comment has been automatically approved."),
                            Category    = (await blogEntry.GetCategoryAsync()).ToString(),
                            Title       = blogEntry.Title.ToString(),
                            Url         = Manager.CurrentSite.MakeUrl(await BlogConfigData.GetEntryCanonicalNameAsync(blogEntry.Identity)),
                            Comment     = Utility.HtmlDecode(model.Comment),
                            UserName    = model.Name,
                            UserEmail   = model.Email,
                            UserWebsite = model.Website,
                        };
                        string subject = this.__ResStr("newComment", "New Blog Comment ({0} - {1})", blogEntry.Title.ToString(), Manager.CurrentSite.SiteDomain);
                        await sendEmail.PrepareEmailMessageAsync(config.NotifyEmail, subject, await sendEmail.GetEmailFileAsync(Package.GetCurrentPackage(this), "New Comment.txt"), Parameters : parms);

                        await sendEmail.SendAsync(true);
                    }

                    if (!blogComment.Approved)
                    {
                        return(FormProcessed(model, this.__ResStr("okSavedReview", "New comment saved - It will be reviewed before becoming publicly viewable"), OnClose: OnCloseEnum.ReloadPage, OnPopupClose: OnPopupCloseEnum.ReloadParentPage));
                    }
                    else
                    {
                        return(FormProcessed(model, this.__ResStr("okSaved", "New comment added"), OnClose: OnCloseEnum.ReloadPage, OnPopupClose: OnPopupCloseEnum.ReloadParentPage));
                    }
                }
            }
        }
Пример #20
0
        public AddModel <CategoryModel> Add(AddModel <CategoryModel> addModel)
        {
            var validator = new FluentValidator <CategoryModel, CategoryValidationRules>(addModel.Item);

            var validationResults = validator.Validate();

            if (!validator.IsValid)
            {
                throw new ValidationException(Messages.DangerInvalidEntitiy)
                      {
                          ValidationResult = validationResults
                      };
            }

            var language = _repositoryLanguage.Get(e => e.Id == addModel.Item.Language.Id);

            if (language == null)
            {
                throw new ParentNotFoundException();
            }

            var line = addModel.Item.CreateMapped <CategoryModel, CategoryLanguageLine>();

            var item = new Category
            {
                Code         = addModel.Item.Code,
                Id           = GuidHelper.NewGuid(),
                CreationTime = DateTime.Now,
                Creator      = _serviceMain.IdentityUser,

                LastModificationTime = DateTime.Now,
                LastModifier         = _serviceMain.IdentityUser
            };

            var affectedItem = _repositoryCategory.Add(item, true);

            var maxLineDisplayOrder = _repositoryCategoryLanguageLine.Get().Where(x => x.Language.Id == addModel.Item.Language.Id).Max(e => e.DisplayOrder);

            line.Id                   = GuidHelper.NewGuid();
            line.Version              = 1;
            line.DisplayOrder         = maxLineDisplayOrder + 1;
            line.CreationTime         = DateTime.Now;
            line.Language             = language;
            line.Category             = affectedItem;
            line.LastModificationTime = DateTime.Now;
            line.Creator              = _serviceMain.IdentityUser;
            line.LastModifier         = _serviceMain.IdentityUser;
            _repositoryCategoryLanguageLine.Add(line, true);


            addModel.Item = affectedItem.CreateMapped <Category, CategoryModel>();



            addModel.Item.Creator      = new IdName(_serviceMain.IdentityUser.Id, _serviceMain.IdentityUser.Person.DisplayName);
            addModel.Item.LastModifier = new IdName(_serviceMain.IdentityUser.Id, _serviceMain.IdentityUser.Person.DisplayName);
            addModel.Item.Language     = new IdCodeName(language.Id, language.Code, language.Name);
            return(addModel);
        }
Пример #21
0
        public ActionResult AddExtension()
        {
            AddModel model = new AddModel {
            };

            ObjectSupport.CopyData(new ExtensionEntry(), model);
            return(View(model));
        }
Пример #22
0
        public ActionResult Models()
        {
            var viewModel = new AddModel();

            viewModel.AdminMakes  = MakeRepositoryFactory.GetMakeRepository().GetMakes();
            viewModel.AdminModels = ModelRepositoryFactory.GetModelRepository().GetModels();
            return(View(viewModel));
        }
        public IActionResult Add([FromBody] AddModel model)
        {
            var mappedModel = _mapper.Map <Model>(model);

            var response = _service.Add(mappedModel);

            return(Ok(response));
        }
        public async void CreateFailing()
        {
            AddModel model = new AddModel(null);

            model.Order = new NewOrderViewModel();
            ValidateModel(model.Order, model);
            Assert.NotNull(await model.OnPostAsync());
        }
Пример #25
0
        public ActionResult AddHoliday()
        {
            AddModel model = new AddModel {
            };

            ObjectSupport.CopyData(new HolidayEntry(), model);
            return(View(model));
        }
Пример #26
0
        public ActionResult AddBlockedNumber()
        {
            AddModel model = new AddModel {
            };

            ObjectSupport.CopyData(new BlockedNumberEntry(), model);
            return(View(model));
        }
Пример #27
0
 private Message ConstructMessageObject(AddModel addModel, double sum)
 {
     return(new Message {
         FirstNumber = addModel.Number1,
         SecondNumber = addModel.Number2,
         Sum = sum
     });
 }
Пример #28
0
        public ActionResult EntryAdd(int?blogCategory)
        {
            AddModel model = new AddModel {
                CategoryIdentity = blogCategory ?? 0
            };

            return(View(model));
        }
Пример #29
0
        public ActionResult UnifiedSetAdd()
        {
            AddModel model = new AddModel {
            };

            ObjectSupport.CopyData(new UnifiedSetData(), model);
            return(View(model));
        }
Пример #30
0
        public AddModel <ParameterModel> Add(AddModel <ParameterModel> addModel)
        {
            var validator = new FluentValidator <ParameterModel, ParameterValidationRules>(addModel.Item);

            var validationResults = validator.Validate();

            if (!validator.IsValid)
            {
                throw new ValidationException(Messages.DangerInvalidEntitiy)
                      {
                          ValidationResult = validationResults
                      };
            }

            var parent = _repositoryParameterGroup.Get(e => e.Id == addModel.Item.ParameterGroup.Id);

            if (parent == null)
            {
                throw new ParentNotFoundException();
            }

            var item = addModel.Item.CreateMapped <ParameterModel, Parameter>();

            if (_repositoryParameter.Get().FirstOrDefault(e => e.Key == item.Key) != null)
            {
                throw new DuplicateException(string.Format(Messages.DangerFieldDuplicated, Dictionary.Key));
            }

            item.Id = GuidHelper.NewGuid();

            item.Version = 1;

            item.CreationTime = DateTime.Now;

            item.LastModificationTime = DateTime.Now;

            item.ParameterGroup = parent;

            item.DisplayOrder = 1;

            item.Creator      = _serviceMain.IdentityUser ?? throw new IdentityUserException(Messages.DangerIdentityUserNotFound);
            item.LastModifier = _serviceMain.IdentityUser;

            _repositoryParameter.Add(item, true);

            var maxDisplayOrder = _repositoryParameter.Get().Max(e => e.DisplayOrder);

            item.DisplayOrder = maxDisplayOrder + 1;

            var affectedItem = _repositoryParameter.Update(item, true);

            addModel.Item = affectedItem.CreateMapped <Parameter, ParameterModel>();

            addModel.Item.Creator        = new IdName(_serviceMain.IdentityUser.Id, _serviceMain.IdentityUser.Person.DisplayName);
            addModel.Item.LastModifier   = new IdName(_serviceMain.IdentityUser.Id, _serviceMain.IdentityUser.Person.DisplayName);
            addModel.Item.ParameterGroup = new IdCodeName(parent.Id, parent.Code, parent.Name);
            return(addModel);
        }