public IActionResult AddBanGuarantee(GuaranteeView request) { request.UserId = _httpContextAccessor.HttpContext.Request.Cookies["UserId"]; var response = _iAddGuaranteeService.AddBanGuarantee(request); return(RedirectToAction("Index", "AdminReport")); }
public IActionResult AddBanGuarantee(GuaranteeView view) { var response = _addGuarantee.AddBanGuarantee(view); if (response.isSuccess == false) { return(null); } return(Ok(response)); }
public TblSshMachineryServicesResponse AddBanGuarantee(GuaranteeView view) { string userId = view.UserId; TblSshMachineryServicesResponse response = new TblSshMachineryServicesResponse(); var machineControl = context.TblSshMachinesRepository.Get().SingleOrDefault(a => a.SerialNo == view.SerialNo); if (machineControl == null) { response.ErrorMessage = view.SerialNo + " " + "Seri numarasına ait makine kurulumu bulunmaktadır."; response.isSuccess = false; } else { try { var machineDetail = _dbContext.sp_SSH_GetSkuBySerial.FromSqlInterpolated($"EXECUTE dbo.sp_SSH_GetSkuBySerial {view.SerialNo}").ToList(); view.SkuCode = machineDetail[0].Sku; view.TracingName = Convert.ToString(machineDetail[0].SkuId); TblSshMachineryServices machineryServices = new TblSshMachineryServices(); //makine hizmetleri tablosunu kurulum olarak kaydediyoruz machineryServices.MachineId = machineControl.MachineId; machineryServices.SkuCode = view.SkuCode; machineryServices.SerialNo = view.SerialNo; machineryServices.TracingName = view.TracingName; machineryServices.GuaranteeComment = view.Comment; machineryServices.GuaranteeBanDate = DateTime.ParseExact(view.BanDate, "dd/mm/yyyy", CultureInfo.InvariantCulture); machineryServices.IsApproved = true; machineryServices.IsRejected = false; machineryServices.ReadFlags = false; machineryServices.ServiceTypeId = 6; machineryServices.FileNames = view.FileNames; machineryServices.CreatedBy = Convert.ToInt32(userId); machineryServices.CreatedDate = DateTime.Now; bool kaydedildiMi = context.TblSshMachineryServicesRepository.Insert(machineryServices); context.Save(); if (kaydedildiMi == false) { response.isSuccess = false; response.ErrorMessage = "Hata oluştu! Lütfen tekrar deneyiniz.."; } else { response.isSuccess = true; response.ErrorMessage = ""; } } catch (Exception) { response.isSuccess = false; response.ErrorMessage = "Hata oluştu! Lütfen tekrar deneyiniz.."; } } return(response); }
public TblSshMachineryServicesResponse AddGuarantee(GuaranteeView view) { string fileName = ""; string uniqueFileName = null; if (view.files != null && view.files.Count > 0) { foreach (IFormFile photo in view.files) { string[] paths = { @"C:\", "Files", "ACS", "Services" }; string uploadsFolder = Path.Combine(paths); uniqueFileName = Guid.NewGuid().ToString() + "_" + photo.FileName; if (photo.ContentType == "image/jpeg") { Image image = Image.FromStream(photo.OpenReadStream(), true, true); int origWidth = image.Width; int origHeight = image.Height; int sngRatio = origWidth / origHeight; int bannerWidth = origWidth / 2; int bannerHeight = origHeight / 2; if (image.Width > 1024) { Bitmap bannerBMP = new Bitmap(image, bannerWidth, bannerHeight); Graphics oGraphics = Graphics.FromImage(bannerBMP); oGraphics = Graphics.FromImage(bannerBMP); // Set the properties for the new graphic file oGraphics.SmoothingMode = SmoothingMode.AntiAlias; oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic; // Draw the new graphic based on the resized bitmap oGraphics.DrawImage(image, 0, 0, bannerWidth, bannerHeight); // Save the new graphic file to the server bannerBMP.Save(uploadsFolder + "/" + uniqueFileName); bannerBMP.Dispose(); oGraphics.Dispose(); } else { image.Save(uploadsFolder + "/" + uniqueFileName); } } else { string filePath = Path.Combine(uploadsFolder, uniqueFileName); photo.CopyTo(new FileStream(filePath, FileMode.Create)); } if (view.files.IndexOf(photo) == view.files.Count - 1) { fileName += uniqueFileName; } else { fileName += uniqueFileName + "||"; } } } view.files = null; view.FileNames = fileName; var request = new RestRequest("api/AddGuarantee/AddGuarantee", Method.POST, DataFormat.Json) .AddJsonBody(view); var resp = Globals.ApiClient.Execute <TblSshMachineryServicesResponse>(request); return(resp.Data); }