public async System.Threading.Tasks.Task <int> GenerateSubscriptionReportsAsync(Subscription sub, int reportProcessorRunId) { reportsGeneratedForThisSubscription = 0; if (sub != null) { //Insert report record var report = _reportService.Add(new Entity.Model.Reporting.Report() { SubscriptionId = sub.Id, Type = (int)ReportTypeEnum.SubscriptionReport, CreationTime = DateTime.UtcNow, ReportProcessorRunId = reportProcessorRunId }); // Usage Sub Report var licenceDetailsObj = await FillUsageReportAsync(sub, report.Id); reportsGeneratedForThisSubscription++; //DeviceOsReport + DevManufacturerReport + DeviceTypeReport + SeatDetailsReport ExtractLicenceObjectAndFillReports(licenceDetailsObj, report.Id); //Update report record report.CompletionTime = DateTime.UtcNow; _reportService.Update(report); } return(reportsGeneratedForThisSubscription); }
public async Task <IActionResult> AddReport(ReportAddDto model) { if (ModelState.IsValid) { var entity = _mapper.Map <ReportEntity>(model); _reportService.Add(entity); // rolü admin olan kullanıcılara bildirim eklenecek var adminUsers = await _userManager.GetUsersInRoleAsync(RoleInfo.Admin); var activeUser = await GetOnlineUser(); foreach (var adminUser in adminUsers) { _notificationService.Add(new NotificationEntity { State = false, AppUserId = adminUser.Id, Description = $"{activeUser.Name} {activeUser.Surname} yeni bir rapor yazdı." }); } return(RedirectToAction("Index")); } return(View(model)); }
public IActionResult PostReports(string id, Report report) { string userId; try { userId = User.Claims.First(c => c.Type == "UserID").Value; } catch { return(Unauthorized()); } var sender = _userService.GetSingleByCondition(s => s.Id == userId, null); var receiver = _userService.GetSingleByCondition(s => s.Id == id, null); if (sender == null || receiver == null) { return(NotFound()); } report.CreateDate = DateTime.Now; report.Sender = sender; report.Receiver = receiver; _reportService.Add(report); _reportService.SaveChanges(); return(Ok(report)); }
public async Task <IActionResult> AddReport(ReportAddDto model) { TempData["Active"] = TempDataInfo.Job; if (ModelState.IsValid) { _reportService.Add(new Report() { JobId = model.JobId, Detay = model.Detay, Basliq = model.Basliq }); var adminUserList = await _userManager.GetUsersInRoleAsync("Admin"); var aktivIstifadeci = await GirisEdenIstifadeci(); foreach (var admin in adminUserList) { _bildirimService.Add(new Bildirim() { Aciqlama = $"{aktivIstifadeci.Name} {aktivIstifadeci.SurName} yeni bir hesabat yazdi", UserId = admin.Id }); } return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult AddReport([FromBody] ReportAPI report) { var result = _reportService.Add(new ReportDTO { Name = report.Name }); return(Ok(result)); }
public IActionResult Add(Report report) { var result = _reportService.Add(report); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public ActionResult Add(Report Report) { if (ReportService.Add(Report)) { return(Redirect("Report")); } else { return(Content("no")); } }
public async Task <ActionResult <ReportViewModel> > Add(ReportViewModel reportViewModel) { if (!ModelState.IsValid) { return(FormattedResponse(ModelState)); } await _reportService.Add(_mapper.Map <Report>(reportViewModel)); return(FormattedResponse(reportViewModel)); }
public async Task <IActionResult> CreateReport([FromBody] ReportDto reportDto) { if (reportDto == null) { return(BadRequest()); } await _iReportsService.Add(reportDto); return(Created("Created new report", reportDto)); }
public IActionResult Post(int customerId, [FromBody] Report report) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } reportService.Add(report); return(CreatedAtRoute("GetReportById", new { customerId, reportId = report.Id }, report)); }
public async Task <ActionResult> Post( ReportInsertDto report, [FromServices] ReportStatusUpdate statusUpdater ) { Report newReport = _mapper.Map <Report>(report); newReport.CreationDate = DateTime.Now; var city = await _geolocation.GetCityInfoFromLocation( report.Latitude, report.Longitude ); IEnumerable <City> cities = new List <City>(); if (city != null) { cities = await _cityRepository.Find( c => c.Name.ToLower().Contains(city.Name.ToLower()) ); } var cityFromRepo = cities.FirstOrDefault(); if (cityFromRepo == null) { NotifyError("As coordenadas informadas não estão cadastradas."); return(CustomResponse()); } newReport.CityId = cityFromRepo.Id; newReport.Street = city.Street; newReport.Neighborhood = city.Neighborhood; await _service.Add(newReport); if (ValidOperation()) { var created = await _repository.GetById(newReport.Id); await statusUpdater.StatusUpdate( newReport.UserId, newReport.Id, newReport.ReportStatusId, "Denúncia criada" ); return(CreatedAtAction(nameof(GetById), new { Id = newReport.Id, Version = "1.0" }, created)); } return(CustomResponse()); }
public IActionResult ReportAnUser([FromBody] Report param) { if (param == null) { return(BadRequest()); } var identity = (ClaimsIdentity)User.Identity; var userId = identity.FindFirst("user_id").Value; param.Id = ObjectId.GenerateNewId().ToString(); param.Date = DateTime.Now; param.ReporterId = userId; return(Ok(_reportService.Add(param))); }
public JsonResult Report(Models.ReportModelView reportModel) { postService.ReportPost(reportModel.postId); //add a report to the reports table and also set the //isreported attribute of that post to true Reports report = new Reports(); report.postId = reportModel.postId; report.reason = reportModel.reason; report.reportedBy = GetUserSession().userId; reportService.Add(report); string result = "You have been successfully reported the post"; return(Json(result)); }
public IActionResult AddReport(ReportViewmodel reportViewmodel) { var report = _reportService.GetReportById(reportViewmodel.Id); if (report == null) { reportViewmodel.Date = _reportControllerServices.DateParser(reportViewmodel.CurrentMonth); report = Mapper.ViewModelToModelMapping.ReportViewModelToReport(reportViewmodel); _reportService.Add(report); return(Ok(report)); } else { var updatedReport = _reportControllerServices.UpdateReportDeviations(report, _deviationService, reportViewmodel); _reportService.Update(updatedReport); return(Ok(updatedReport)); } }
public IActionResult Edit(ReportDTO dto) { if (ModelState.IsValid) { try { if (dto.IdReport.HasValue) { var res = _reportService.Update(dto); if (res) { return(RedirectToAction("Index")); } return(View(dto)); } else { var res = _reportService.Add(dto); if (res) { return(RedirectToAction("Index")); } return(View(dto)); } } catch (Exception e) { Console.WriteLine(e); throw; } } return(View(dto)); }
public async Task <IActionResult> Create([FromBody] string Tag) { var reportModel = await _reportService.Add(Tag); if (reportModel is not null) { var factory = new ConnectionFactory { HostName = "localhost", UserName = "******", Password = "******", }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { var QueueName = "RAPOROLUSTUR"; var exchangeName = "RAPOROLUSTUR-Exchange"; channel.ExchangeDeclare(exchangeName, ExchangeType.Topic, true); channel.QueueDeclare(QueueName, false, false, false, null); channel.QueueBind(QueueName, exchangeName, ""); var message = $"RAPOROLUSTUR${reportModel.Id}${Tag}"; var body = Encoding.UTF8.GetBytes(message); channel.BasicPublish(exchange: "", routingKey: "", basicProperties: null, body: body); } return(Ok(reportModel)); } else { return(NotFound("Error")); } }
public async Task <IActionResult> Post([FromRoute] string orgRoleId, [FromBody] ReportCreationVM vm) { if (string.IsNullOrWhiteSpace(orgRoleId) || string.IsNullOrEmpty(orgRoleId)) { return(StatusCode(StatusCodes.Status400BadRequest, new BadRequestError($"'{nameof(orgRoleId)}' cannot be null or whitespace"))); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var(name, reportTemplateId, organizationId, parameters) = vm; OrganizationRole organizationRole = organizationRoleService .Get <OrganizationRole>(orgRole => orgRole.Id == orgRoleId, asNoTracking: true); if (organizationRole == null) { return(StatusCode(StatusCodes.Status404NotFound, new NotFoundError($"OrganizationRole not found"))); } Organization organization = organizationService .Get <Organization>(org => org.Id == organizationId, asNoTracking: true); if (organization == null) { return(StatusCode(StatusCodes.Status404NotFound, new NotFoundError($"Organization not found"))); } ReportTemplate reportTemplate = reportTemplateService.Get <ReportTemplate>( rt => rt.Id == reportTemplateId, asNoTracking: true); if (reportTemplate == null) { return(StatusCode(StatusCodes.Status404NotFound, new NotFoundError("ReportTemplate not found"))); } User user = await GetCurrentUser(); if (user is null) { return(StatusCode(StatusCodes.Status404NotFound, new NotFoundError("Current user not found"))); } var reportCreationDto = new ReportCreationDto() { ReportName = name, ReportTemplate = reportTemplate, Organization = organization, OrganizationRole = organizationRole, User = user, Parameters = parameters }; Report report = reportService.Add(reportCreationDto); if (_unitOfWork.SaveChanges() < 0) { return(BadRequest("Error when trying to insert a report")); } ShortReportVM shortReportVM = _typeAdapter.Adapt <Report, ShortReportVM>(report); shortReportVM.CreatedBy = user.UserName; return(CreatedAtAction( actionName: nameof(Get), routeValues: new { version = $"{HttpContext.GetRequestedApiVersion()}", orgRoleId = organizationRole.Id, reportId = report.Id }, value: shortReportVM)); }
public int CreateReport(int employeeId, string text) { ViewReportModel reportModel = new ViewReportModel(employeeId, text); return(service.Add(ConvertModelToBbl(reportModel))); }
public ActionResult Create(ReportViewModel viewModel, HttpPostedFileBase file, string assetID) { string[] listAssetID = assetID.Split(','); List <string> listUserName = new List <string>(); List <string> listMail = new List <string>(); for (int i = 0; i < listAssetID.Length; i++) { int idAsset = Int32.Parse(listAssetID[i]); string name = _reportService.getNameUserReport(idAsset).FullName; string mail = _reportService.getNameUserReport(idAsset).Email; listUserName.Add(name); listMail.Add(mail); } List <String> listMailRecever = new List <string>(); listMailRecever.AddRange(listMail.Distinct()); var mailConfig = _mailConfigService.GetAll().FirstOrDefault(); var listMailConfig = _mailConfigService.GetAll(); string assetReport = _assetService.GetById(Int32.Parse(assetID)).Name; string areaAssetReport = _assetService.GetById(Int32.Parse(assetID), new string[] { "Area" }).Area.Name; string locationAssetReport = _assetService.GetById(Int32.Parse(assetID), new string[] { "Area", "Area.Location" }).Area.Location.Name; string userReport = User.Identity.GetUserName(); var pathTemplate = HttpRuntime.AppDomainAppPath; string body = MailHelper.createContent(pathTemplate, "templates//", "TemplateEmail", new object[] { userReport, assetReport, locationAssetReport, areaAssetReport, viewModel.Comment, DateTime.Now }); foreach (var mail in listMailConfig) { if (mail.DateSend != DateTime.Now.Date) { mail.Count = 0; mail.DateSend = DateTime.Now.Date; } if (mail.Count + listMailRecever.Count <= 2000) { mail.Count += listMailRecever.Count; foreach (var recever in listMailRecever) { MailHelper.SendMail(mailConfig.EmailAddress, mailConfig.Password, mailConfig.Host, mailConfig.Port, mailConfig.EnabledSSL, recever, "Report asset", "cim", body); } break; } _mailConfigService.Update(mail); } //process image upload //set path default string fileName = "default.png"; string path = Path.Combine(Server.MapPath("~/Data/Reports/"), fileName); try { if (file != null) { var fileExtension = Path.GetExtension(file.FileName); if (string.Equals(fileExtension, ".jpg", StringComparison.OrdinalIgnoreCase) || string.Equals(fileExtension, ".png", StringComparison.OrdinalIgnoreCase) || string.Equals(fileExtension, ".gif", StringComparison.OrdinalIgnoreCase) || string.Equals(fileExtension, ".jpeg", StringComparison.OrdinalIgnoreCase)) { fileName = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName); path = Path.Combine(Server.MapPath("~/Data/Reports/"), fileName); } } ; file.SaveAs(path); } catch { } if (ModelState.IsValid) { var userName = User.Identity.GetUserName(); if (string.IsNullOrEmpty(userName)) { userName = "******"; } for (int i = 0; i < listAssetID.Length; i++) { var report = new Report() { AssetID = Int32.Parse(listAssetID[i]), Picture = fileName, RequestManager = listUserName[i], status = 1, ReportAt = DateTime.Now, Active = true, Comment = "- " + viewModel.Comment, CreatedAt = DateTime.Now, UserReport = userName }; _reportService.Add(report); _reportService.SaveChanges(); } ViewBag.isCreateSuccess = true; return(View()); } return(RedirectToAction("Index", "MyReport")); }
public void AddTest_AddNullItem_RepositoryMethodNotInvoked() { _reportService.Add(null); _repository.Verify(x => x.Add(null), Times.Never); }