Ejemplo n.º 1
0
        public ActionResult Index(SubscriptionCreateModel model)
        {
            Subscription subscription = new Subscription
            {
                BlobStorageKey = model.BlobStorageKey,
                BlobStorageName = model.BlobStorageName,
                CertificateKey = model.CertificateKey,
                AzureSubscriptionId = model.AzureSubscriptionId
            };

            BinaryReader r = new BinaryReader(Request.Files[0].InputStream);
            subscription.Certificate = r.ReadBytes(Request.Files[0].ContentLength);

            using (ApplicationDbContext context = new ApplicationDbContext())
            {
                context.Subscriptions.Add(subscription);
                context.SaveChanges();
            }

            return View();
        }
Ejemplo n.º 2
0
        public static Email BuildAssignCertificateEmail(Identity identity, Subscription subscription, byte[] cer)
        {
            string template = GetTemplate("AssignCertificate");

            var emailMessage = new EmailMessage()
            {
                Body =
                    Engine.Razor.RunCompile(
                        template, "assignCertificateTemplate", null,
                        new
                        {
                            User = identity.DisplayName
                        }),
                To = identity.Email,
                Subject = string.Format("Azure Management Certificate"),
                Attachement = cer,
                AttachementName = "Management.cer"
            };

            var email = new Email(new List<EmailMessage> { emailMessage });

            return email;
        }
Ejemplo n.º 3
0
        private void CreateSubscriptionIdentityMap(Subscription subscription, ApplicationDbContext context, string role)
        {
            SubscriptionIdentityRole subscriptionIdentity = new SubscriptionIdentityRole
            {
                Subscription = subscription,
                IdentityId = UnitOfWork.CurrentIdentity.IdentityId,
                Role = role
            };

            context.SubscriptionIdentityRoles.Add(subscriptionIdentity);
        }
Ejemplo n.º 4
0
 private void CreateSubscriptionIdentityMap(Subscription subscription, int identityId)
 {
     using (ApplicationDbContext context = new ApplicationDbContext())
     {
         CreateSubscriptionIdentityMap(subscription, context, RoleTypes.Member);
         CreateSubscriptionIdentityMap(subscription, context, RoleTypes.Owner);
         CreateSubscriptionIdentityMap(subscription, context, RoleTypes.Trainer);
         context.SaveChanges();
     }
 }