public ActionResult GetPdfReport(Int32 habReviewId, DateTime?templateDate)
        {
            if (User == null)
            {
                return(null);
            }
            ConsumerHabReviewsManagement manage = new ConsumerHabReviewsManagement(_context);

            foreach (String key in Session.Keys.Cast <String>().Where(x => x.StartsWith("DocumentPDF_")).ToArray())
            {
                HttpContext.Session.Remove(key);
            }
            String name = "";

            Byte[] bytes = manage.GetPDF(habReviewId, this, out name, templateDate);
            Guid   guid  = Guid.NewGuid();

            Session["DocumentPDF_" + guid]  = bytes;
            Session["DocumentName_" + guid] = name;
            String rootUrl = new Uri(Request.Url, Url.Content("~")).ToString();

            String url = rootUrl + "api/consumerhabreviewsapi/getpdfhandler/" + guid;

            return(Json(new { status = "ok", url = url }));
        }
        public async Task <ActionResult> GetDefaultData(Int32 consumerId)
        {
            if (User == null)
            {
                return(null);
            }
            ConsumerHabReviewsManagement manage = new ConsumerHabReviewsManagement(_context);
            ConsumerHabReviewViewModel   model  = new ConsumerHabReviewViewModel(await manage.GetDefaultModel(consumerId));

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        public async Task <ActionResult> Delete(Int32 id)
        {
            if (User == null)
            {
                return(null);
            }

            ConsumerHabReviewsManagement manage = new ConsumerHabReviewsManagement(_context);

            if (!await manage.Delete(id))
            {
                return(Json(new { status = "error", message = "You can't delete this record. Please contact to support team." }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { status = "ok" }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetAvailableReportTemplates(Int32 reportId)
        {
            if (User == null)
            {
                return(null);
            }

            var manage = new ConsumerHabReviewsManagement(_context);

            var reportTemplates = ReportManager.GetAvailableReportTemplates(Core.Enums.ReportType.ComHabPlanReview, _context);
            var reportDate      = manage.GetHabReview(reportId).DateReview;

            var filteredTemplates = GetFilteredReportTemplates(reportTemplates, reportDate);


            return(Json(new { status = "ok", reportTemplates = filteredTemplates }));
        }
        public async Task <ActionResult> Save(ConsumerHabReviewViewModel model)
        {
            if (User == null)
            {
                return(null);
            }
            ConsumerHabReviewsManagement manage = new ConsumerHabReviewsManagement(_context);
            Int32 id = 0;

            if (model.ConsumerHabReviewId == null)
            {
                model.DateCreated = DateTime.Now;
                id = await manage.Save(model.GetModel());
            }
            else
            {
                id = model.ConsumerHabReviewId.Value;
                await manage.Save(model.GetModel());
            }
            return(Json(new { status = "ok", id = id }));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Get(String id)
        {
            if (User == null)
            {
                return(null);
            }

            if (String.IsNullOrEmpty(id))
            {
                return(null);
            }
            Int32 consumerId = Int32.Parse(id);
            ConsumerManagement                  manage               = new ConsumerManagement(_context);
            ConsumerPhonesManagement            managePhones         = new ConsumerPhonesManagement(_context);
            ConsumerEmployeeManagement          manageEmployees      = new ConsumerEmployeeManagement(_context);
            ConsumerServicesManagement          manageServices       = new ConsumerServicesManagement(_context);
            ConsumerEmployeeDocumentsManagement manageDocuments      = new ConsumerEmployeeDocumentsManagement(_context);
            ConsumerHabPlansManagement          manageHabPlans       = new ConsumerHabPlansManagement(_context);
            ConsumerHabReviewsManagement        manageHabReviews     = new ConsumerHabReviewsManagement(_context);
            ConsumerPrintDocumentsManagement    managePrintDocuments = new ConsumerPrintDocumentsManagement(_context);
            ConsumerCallLogsManagement          manageCallLogs       = new ConsumerCallLogsManagement(_context);
            ConsumerNotesManagement             manageNotes          = new ConsumerNotesManagement(_context);
            ConsumerNotificationsManagement     manageNotifications  = new ConsumerNotificationsManagement(_context);

            var consumer = await manage.GetConsumer(consumerId);

            if (consumer == null)
            {
                return(null);
            }
            var phones = await managePhones.GetPhones(consumerId);

            var employees = await manageEmployees.GetEmployees(consumerId);

            var services = await manageServices.GetServices(consumerId);

            var documents = await manageDocuments.GetDocuments(consumerId);

            var habPlans = await manageHabPlans.GetHabPlans(consumerId);

            var habReviews = await manageHabReviews.GetHabReviews(consumerId);

            var printDocuments = await managePrintDocuments.GetPrintDocuments(consumerId);

            var callLogs = await manageCallLogs.GetCallLogs(consumerId);

            var notes = await manageNotes.GetNotes(consumerId);

            var notifications = await manageNotifications.GetNotifications(consumerId);

            var uploadFiles             = FileDataService.GetConsumerFiles(_context, consumerId);
            ConsumerFullViewModel model = new ConsumerFullViewModel(consumer);

            model.SetPhones(phones);
            model.SetEmployees(employees);
            model.SetApprovedServices(services);
            model.SetDocuments(documents);
            model.SetHabPlans(habPlans);
            model.SetHabReviews(habReviews);
            model.SetPrintDocuments(printDocuments);
            model.SetCallLogs(callLogs);
            model.SetNotes(notes);
            model.SetNotifications(notifications);
            model.SetUploadFiles(uploadFiles);
            return(Json(model, JsonRequestBehavior.AllowGet));
        }