Esempio n. 1
0
        public string GetFileUploadBlobReturnsLink(IFormFile file)
        {
            var    fileName = file.FileName;
            string mime     = file.ContentType;

            byte[] data = GetBytes(file);

            return(_blob.UploadFileToBlob(fileName, data, mime));
        }
Esempio n. 2
0
        public async Task <List <FirmLoginDto> > CreateFirm(Firm firmDetails)
        {
            var rnd = new RNGCryptoServiceProvider();
            var sb  = new StringBuilder();
            var buf = new byte[3]; //length: should be larger

            rnd.GetBytes(buf);

            //gives a "valid" range of: "0123456789ABCDEF"
            foreach (byte b in buf)
            {
                sb.AppendFormat("{0:x2}", b);
            }
            string passwordHash, passwordSalt;


            CreatePasswordHash(firmDetails.Password, out passwordHash, out passwordSalt);

            firmDetails.PasswordHash = passwordHash;
            firmDetails.PasswordSalt = passwordSalt;
            firmDetails.LoginId      = sb.ToString();

            if (firmDetails.imageFile1 == null)
            {
                firmDetails.ImageUri = "#";
            }
            else
            {
                var    imageFileName = firmDetails.imageFile1.FileName;
                string imageMimeType = firmDetails.imageFile1.ContentType;
                byte[] imageData     = PropertyManager.GetBytes(firmDetails.imageFile1);

                firmDetails.ImageUri = _blob.UploadFileToBlob(imageFileName, imageData, imageMimeType);
            }


            List <Firm> firmsCreated = ListofCreatedFirms(firmDetails);

            _db.AddRange(firmsCreated);

            await _db.SaveChangesAsync();


            // return new FirmLoginDto(){
            //     LoginId = firmDetails.LoginId,
            //     Password = firmDetails.Password,
            //     Id = firmDetails.Id
            // };

            foreach (var item in firmsCreated)
            {
                _subRepo.CreateSubscription(item.LoginId, item.Plan, item.Email);
            }

            return(LoginDetails(firmsCreated));
        }