Ejemplo n.º 1
0
        public override async Task <PointRankDto> Update(PointRankDto input)
        {
            CheckUpdatePermission();

            var entity = await _pointRankRepository.GetAsync(input.Id);

            if (entity == null)
            {
                throw new EntityNotFoundException(typeof(PointRank), input.Id);
            }

            var oldAvatar = entity.Avatar;

            CheckErrors(await CheckNameOrMinPointAsync(input.Id, input.Name, input.MinPoint));

            MapToEntity(input, entity);

            entity = await _pointRankRepository.UpdateAsync(entity);

            //头像文件处理
            if (oldAvatar != entity.Avatar)
            {
                uploadHelper.MoveFile(entity.Avatar, UploadType.PointAvatar, FileType.Image, AbpSession.UserId);

                uploadHelper.DeleteFile(oldAvatar, UploadType.PointAvatar, FileType.Image);
            }

            return(MapToEntityDto(entity));
        }
Ejemplo n.º 2
0
        public ApiResult UploadPhoto()
        {
            UserModel userModel = Auth.GetLoginUser(_httpContext);
            string    oldPath   = userModel.HeadPhoto;

            if (!string.IsNullOrEmpty(oldPath))
            {
                UploadHelper.DeleteFile(oldPath);
            }
            var       file      = Request.Form.Files[0];
            PathValue pathValue = UploadHelper.SaveFile(file.FileName);

            UploadHelper.CompressImage(pathValue.FilePath, file.OpenReadStream(), 168, 168, true);
            pathValue           = UploadHelper.Upload(pathValue.FilePath, file.FileName).GetAwaiter().GetResult();
            userModel.HeadPhoto = pathValue.FilePath;
            _userService.Update(userModel);
            IList <Claim> claims = new List <Claim>()
            {
                new Claim("account", userModel.Account),
                new Claim("username", userModel.Username),
                new Claim("sex", userModel.Sex),
                new Claim("birthDate", string.IsNullOrEmpty(userModel.BirthDate)?"":userModel.BirthDate),
                new Claim("email", string.IsNullOrEmpty(userModel.Email)?"":userModel.Email),
                new Claim("sign", string.IsNullOrEmpty(userModel.Sign)?"":userModel.Sign),
                new Claim("phone", userModel.Phone),
                new Claim("headPhoto", userModel.HeadPhoto)
            };
            string jwtToken = new JWT(_cacheClient).CreateToken(claims);

            return(ApiResult.Success(new { Path = pathValue.FilePath, token = jwtToken }));
        }
Ejemplo n.º 3
0
 private void DeleteFile()
 {
     if (input.Group == GROUP_ITEM)
     {
         UploadHelper.DeleteFile(input.FullUrlImageSmall);
         UploadHelper.DeleteFile(input.FullUrlImageNormal);
         UploadHelper.DeleteFile(input.FullUrlImageLarger);
     }
 }
Ejemplo n.º 4
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var shopFile = await _context.ShopFiles.SingleOrDefaultAsync(m => m.ID == id);

            var helper = new UploadHelper(_environment);

            helper.DeleteFile("files", shopFile.Filename);
            _context.ShopFiles.Remove(shopFile);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var paymend = await _context.Paymends.SingleOrDefaultAsync(m => m.ID == id);

            var helper = new UploadHelper(_environment);

            helper.DeleteFile("images/paymend", paymend.LogoUrl);
            _context.Paymends.Remove(paymend);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var productImage = await _context.ProductImages.SingleOrDefaultAsync(m => m.ProductImageID == id);

            var helper = new UploadHelper(_environment);

            helper.DeleteFile("images/store", productImage.ImageUrl);
            _context.ProductImages.Remove(productImage);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 7
0
        public ActionResult RemoveFile(string[] fileNames, string certificateId)
        {
            // The parameter of the Remove action must be called "fileNames"

            if (fileNames != null)
            {
                foreach (var fullName in fileNames)
                {
                    var fileName = Path.GetFileName(fullName);
                    UploadHelper.DeleteFile(certificateId, fileName);
                }
            }

            // Return an empty string to signify success
            return(Content(""));
        }
Ejemplo n.º 8
0
        public ActionResult Remove(string[] fileNames, string documentId)
        {
            // The parameter of the Remove action must be called "fileNames"

            if (fileNames != null)
            {
                foreach (var fullName in fileNames)
                {
                    var fileName = Path.GetFileName(fullName);
                    UploadHelper.DeleteFile(documentId, fileName);
                    //var physicalPath = Path.Combine(Server.MapPath("~/App_Data"), fileName);

                    //// bbnrrf TODO: Verify user permissions

                    //if (System.IO.File.Exists(physicalPath)) {
                    //	// The files are not actually removed in this demo
                    //	// System.IO.File.Delete(physicalPath);
                    //}
                }
            }

            // Return an empty string to signify success
            return(Content(""));
        }
        public async Task <IActionResult> EMailSend([Bind("OrderID, Email, Subject, Message, Attachments")] OrderEmailViewModel orderEmail)
        {
            if (ModelState.IsValid)
            {
                OrderViewModel vm   = null;
                BankAcccount   bank = null;

                if (orderEmail.OrderID == null)
                {
                    return(NotFound());
                }
                else
                {
                    vm = await GetOrderViewModel(orderEmail.OrderID);

                    bank = await _context.BankAcccounts.FirstOrDefaultAsync();

                    string bill = $"<h2>Hallo Frau/Herr {vm.CutomerLastName},</h2>" +
                                  $"<p>noch einmal vielen Dank für Ihren Einkauf.</p>" +
                                  $"<p>Bitte überweisen Sie den Gesamtbetrag von <b>{Math.Round(vm.Total, 2)} &euro;</b> innerhalb von 7 Tagen unter Angabe der Rechungsnummer:<br/>" +
                                  $"<b>{orderEmail.Message}</b><br />" +
                                  $"auf das folgende Konto:</p>" +
                                  $"<br />" +
                                  $"<p>Kontoinhaber:<b> {bank.AccountOwner}</b><br />" +
                                  $"IBAN: <b>{bank.Iban}</b><br />" +
                                  $"SWIFT-BIC: <b>{bank.SwiftBic}</b><br />" +
                                  $"Bank: <b>{bank.Institute}</b></p><br />";
                    bill += $"<hr /><h3>Rechungsdetails</h3>" +
                            $"<p>Ihre Bestellung vom {vm.OrderDate.ToShortDateString()}</p>";
                    if (!string.IsNullOrWhiteSpace(vm.FreeText))
                    {
                        bill += $"<p>Ihre Angaben zur Bestellung: <b>{vm.FreeText}</b></p>";
                    }
                    bill += $"<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" height=\"15%\" width=\"75%\"><tr><th>Position</th><th>Artikel-Nr.</th><th>Artikelname</th><th>Menge</th><th>Betrag</th></tr>";
                    foreach (var item in vm.OderLines)
                    {
                        bill += $"<tr><td align=\"center\">{item.Position}</td>" +
                                $"<td align=\"center\">{item.ProductNumber}</td>" +
                                $"<td align=\"center\">{item.ProductName}</td>" +
                                $"<td align=\"center\">{Math.Round(item.OrderQuantity, 2)} {item.OrderUnit}</td>" +
                                $"<td align=\"center\">{Math.Round(item.OrderLineTotal,2)} &euro;</td></tr>";
                    }
                    bill += $"</table><br />" +
                            $"<table cellpadding=\"0\" cellspacing=\"1\" height=\"5%\" width=\"85%\">" +
                            $"<tr>" +
                            $"<td align=\"right\" colspan=\"4\">Versand, {vm.ShippingPriceName}:</td>" +
                            $"<td>{Math.Round(vm.ShippingPriceAtOrder,2)} &euro;</td></tr>" +
                            $"<tr>" +
                            $"<td align=\"right\" colspan=\"4\">Gesamtbetrag:</td><td>{Math.Round(vm.Total,2)} &euro;</td></tr>" +
                            $"</table>" +
                            $"<br />" +
                            $"<p>Die Lieferfrist beginnt mit der Zahlungsanweisung.</p>" +
                            $"<br />" +
                            $"<p>Viele Gr&uuml;&szlig;e,</p><p>Petra Buron</p><br />";
                    var attachments = new List <string>();
                    var files       = HttpContext.Request.Form.Files;
                    if (files != null && files.Count > 0)
                    {
                        //var file = files.First();
                        var helper = new UploadHelper(_environment);
                        var todel  = new List <string>();


                        foreach (var file in files)
                        {
                            var fnames = await helper.FileUploadAsync(file, "files", false);

                            todel.Add(fnames.Filename);
                            attachments.Add(fnames.Filename);
                        }

                        foreach (string file in todel)
                        {
                            helper.DeleteFile("files", file);
                        }
                    }

                    var agb = await _context.ShopFiles.SingleAsync(s => s.ShopFileType == Enums.ShopFileTypeEnum.AGB);

                    var wiederruf = await _context.ShopFiles.SingleAsync(s => s.ShopFileType == Enums.ShopFileTypeEnum.WRB);

                    var datenschutz = await _context.ShopFiles.SingleAsync(s => s.ShopFileType == Enums.ShopFileTypeEnum.DSK);

                    attachments.Add(agb.Filename);
                    attachments.Add(wiederruf.Filename);
                    attachments.Add(datenschutz.Filename);

                    await _emailSender.SendEmailWithAttachmentsAsync(orderEmail.Email, orderEmail.Subject, bill, attachments);

                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(View(orderEmail));
        }