Exemplo n.º 1
0
        public ActionResult PackageAssembled(int packageId)
        {
            var request = new PackageAssembledRequest { PackageId = packageId };
            var response = this.packagesService.PackageAssembled(request);

            var jsonNetResult = new JsonNetResult
            {
                Formatting = (Formatting)Newtonsoft.Json.Formatting.Indented,
                Data = response.ConvertToPackageViewModel()
            };
            return jsonNetResult;
        }
Exemplo n.º 2
0
        /// <summary>
        /// The package assembled.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="PackageAssembledResponse"/>.
        /// </returns>
        public PackageAssembledResponse PackageAssembled(PackageAssembledRequest request)
        {
            try
            {
                var package = this.packageRepository.GetPackageById(request.PackageId);
                package.ChangePackageStatus(PackageStatus.Assembled);
                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("Assembling"),
                        profile.GetTranslatedPackageStatus("Assembled"),
                        profile.GetFullName());
                    this.emailService.SendMail(
                        EmailResources.EmailActivationFrom,
                        package.User.Email,
                        profile.GetEmailResourceString("PackageStatusChangedSubject"),
                        body);
                }

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