コード例 #1
0
        public ActionResult AssemblePackage(int packageId)
        {
            var request = new AssemblePackageRequest { PackageId = packageId };
            var response = this.packagesService.AssemblePackage(request);

            var jsonNetResult = new JsonNetResult
            {
                Formatting = (Formatting)Newtonsoft.Json.Formatting.Indented,
                Data = response.ConvertToPackageViewModel()
            };
            return jsonNetResult;
        }
コード例 #2
0
        /// <summary>
        /// The assemble package.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="AssemblePackageResponse"/>.
        /// </returns>
        public AssemblePackageResponse AssemblePackage(AssemblePackageRequest request)
        {
            try
            {
                var package = this.packageRepository.GetPackageById(request.PackageId);
                package.ChangePackageStatus(PackageStatus.Assembling);
                this.packageRepository.UpdatePackage(package);

                if (package.User.Activated)
                {
                    var profile = package.User.Profile;
                    var body = string.Format(
                        profile.GetEmailResourceString("PackageStatusChangedBody"),
                        package.Name,
                        package.Id,
                        profile.GetTranslatedPackageStatus("New"),
                        profile.GetTranslatedPackageStatus("Assembling"),
                        profile.GetFullName());
                    this.emailService.SendMail(
                        EmailResources.EmailActivationFrom,
                        package.User.Email,
                        profile.GetEmailResourceString("PackageStatusChangedSubject"),
                        body);
                }

                var response = package.ConvertToAssemblePackageResponse();
                response.MessageType = MessageType.Success;
                response.Message = string.Format(PackageStatusResources.StatusChanged, PackageStatus.Assembling);
                return response;
            }
            catch (Exception ex)
            {
                this.Logger.Log(ex.Message);
                return new AssemblePackageResponse { MessageType = MessageType.Error, Message = ex.Message };
            }
        }