public void Create(string package, string email, string mobile, string twitter)
        {
            if (string.IsNullOrWhiteSpace(package))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(package));
            }

            if (string.IsNullOrWhiteSpace(email) ||
                string.IsNullOrWhiteSpace(mobile) ||
                string.IsNullOrWhiteSpace(twitter))
            {
                throw new ArgumentException("At least one notification target must be specified.");
            }

            var corePackage = _packageService.Exists(package)
                ? _packageService.Get(package)
                : _packageService.Create(package);

            if (corePackage == null)
            {
                throw new NullReferenceException("A package must exist to create a package notification.");
            }

            Create(corePackage, PackageNotificationType.Email, email);
            Create(corePackage, PackageNotificationType.Mobile, mobile);
            Create(corePackage, PackageNotificationType.Twitter, twitter);
        }
        public async Task <IActionResult> Create(CreatePackageViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            await _packageService.Create(model);

            return(RedirectToAction("Index", "Home"));
        }
        public IActionResult Create(PackageInputModel package)
        {
            if (!ModelState.IsValid)
            {
                return(Redirect("/Packages/Create"));
            }

            packageService.Create(package.Description, package.Weight, package.ShippingAddress, package.RecipientName);

            return(Redirect("/Packages/Pending"));
        }
        public IActionResult Create(PackageCreateInputModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewData["Users"] = packageService.GetAllRecipients();
                return(View(model));
            }

            packageService.Create(model);
            return(RedirectToAction("Index", "Home"));
        }
Example #5
0
        public ActionResult <Package> Post(Package package)
        {
            try
            {
                return(Ok(_PackService.Create(package)));
            }

            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Example #6
0
        //the two below action method used for create Package
        public virtual JsonResult CalculatedUltimated(PackageAddViewModel model)
        {
            var package = new Package {
                DisCountPrice = model.DisCountPrice, StartDate = model.StartDate, EndDate = model.EndDate, Explain = model.Explain, Name = model.Name, OriginalPrice = model.OriginalPrice, Percent = model.Percent
            };

            _packageService.Create(package);
            if (_unitOfWork.SaveAllChanges() > 0)
            {
                int Id = package.Id;
                return(Json(new { Id = Id }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { Id = -1 }, JsonRequestBehavior.AllowGet));
        }
        public void NewProject(string folder, string name)
        {
            string         path    = Path.Combine(folder, name + Constant.PROJECT_FILE_EXTENSION);
            IPackage       package = _packageService.Create(path);
            ProjectSummary summary = new ProjectSummary();

            summary.FirstRun = true;
            package.AddFileContent(summary.ToXml(), Constant.PACKAGE_SUMMARY_FILE_NAME);
            ProjectEntityDev projectEntity = new ProjectEntityDev();

            projectEntity.Name             = name;
            projectEntity.Code             = "NewProject";
            projectEntity.UserModel        = true;
            projectEntity.UserPopedomModel = true;
            projectEntity.UserSubsequent   = true;
            package.AddFileContent(projectEntity.ToXml(), Constant.PACKAGE_PROJECT_FILE_NAME);
            package.Close();
            ProjectEventArgs args = new ProjectEventArgs(path);

            _eventAggregator.GetEvent <ProjectCreatedEvent>().Publish(args);
        }
 public void Post([FromBody] PackagePostModel packagePostModel)
 {
     //   User addedBy = usersService.GetCurrentUser(HttpContext);
     packageService.Create(packagePostModel);
 }
        public async Task <IActionResult> Create([FromBody] Package package)
        {
            await _packageService.Create(package);

            return(Ok());
        }