示例#1
0
        public async Task <ActionResult> ConfirmUser(UserConfirmModel model)
        {
            try
            {
                // Save user credentials
                User user = await _users.SaveUserCredentials(model.Token, model.Password);

                // Audit log
                _auditLog.Log(AuditStream.UserSecurity, "Registration Completed",
                              new
                {
                    userId = user.ID
                },
                              new
                {
                    remote_ip = Request.UserHostAddress,
                    browser   = Request.Browser.Browser
                });
            }
            catch (EmailExpiredException)
            {
                return(View("EmailLinkExpired", new Models.ErrorModel {
                    Message = ConfigurationManager.AppSettings["DataLinkerContactEmail"]
                }));
            }

            Toastr.Success("Email verification process was successfully completed.");

            return(View("EmailConfirmed", new Models.ErrorModel()));
        }
示例#2
0
        protected void AddToCart_Click(object sender, EventArgs e)
        {
            // Pizza list
            List <Pizza> list;

            int    pizzaid  = int.Parse(MenuGrid.Rows[((GridViewRow)((Control)sender).NamingContainer).RowIndex].Cells[0].Text);
            string name     = MenuGrid.Rows[((GridViewRow)((Control)sender).NamingContainer).RowIndex].Cells[1].Text;
            string toppings = MenuGrid.Rows[((GridViewRow)((Control)sender).NamingContainer).RowIndex].Cells[2].Text;
            float  price    = float.Parse(MenuGrid.Rows[((GridViewRow)((Control)sender).NamingContainer).RowIndex].Cells[3].Text);

            if (Session["cart"] == null)
            {
                list = new List <Pizza>();
                list.Add(new Pizza(pizzaid, name, toppings, price));
                Session["cart"] = list;

                Toastr.Success(this.Page, $"{name} added to cart!", "SUCCESS");
            }
            else
            {
                list = (List <Pizza>)Session["cart"];
                list.Add(new Pizza(pizzaid, name, toppings, price));
                Session["cart"] = list;

                Toastr.Success(this.Page, $"{name} added to cart!", "SUCCESS");
            }
        }
示例#3
0
        public ActionResult Edit(int id, Models.Applications.ApplicationDetails appDetails)
        {
            var urlToApps = Url.Action("Index", "Applications", null, Request.Url.Scheme);

            // Setup name
            var model = (ApplicationDetails)appDetails;

            model.Name = appDetails.Name;

            // edit application
            Application application = _applications.EditApplication(id, urlToApps, model, LoggedInUser);

            // Log industry good action
            if (application.IsIntroducedAsIndustryGood && appDetails.IsIntroducedAsIndustryGood && !application.IsVerifiedAsIndustryGood)
            {
                _auditLog.Log(AuditStream.UserActivity, "Industry Good",
                              new
                {
                    id    = LoggedInUser.ID,
                    email = LoggedInUser.Email
                },
                              new
                {
                    remote_ip = Request.UserHostAddress,
                    browser   = Request.Browser.Browser
                });
            }

            // Setup status
            Toastr.Success("Application was successfully updated.");

            // Return result
            return(RedirectToAction("Details", new { id = application.ID }));
        }
示例#4
0
        public ActionResult Create(string appType, Models.Applications.NewApplicationDetails model)
        {
            // Setup url for notification
            var url = Url.Action("Index", "Applications", null, Request.Url.Scheme);

            // Setup name
            var data = (NewApplicationDetails)model;

            data.Name = model.Name;

            // Create application
            Application application = _applications.Create(url, model, LoggedInUser);

            // Log details for industry good application
            if (application.IsIntroducedAsIndustryGood)
            {
                // Log industry good action
                _auditLog.Log(AuditStream.General, "Industry Good",
                              new
                {
                    id    = LoggedInUser.ID,
                    email = LoggedInUser.Email
                },
                              new
                {
                    remote_ip = Request.UserHostAddress,
                    browser   = Request.Browser.Browser
                });
            }

            // Setup status message
            Toastr.Success("Service was successfully created");
            return(RedirectToAction("Details", new { id = application.ID }));
        }
示例#5
0
        public ActionResult Create(SchemaModel model)
        {
            // Check whether file present
            if (model.UploadFile == null)
            {
                Toastr.Error("You should upload a schema");
                return(View(model));
            }

            // Setup stream
            var stream = new MemoryStream();

            model.UploadFile.InputStream.CopyTo(stream);

            // Setup model
            var newSchema = new DataLinker.Models.SchemaModel
            {
                Description    = model.Description,
                PublicId       = model.PublicId,
                IsAggregate    = model.IsAggregate,
                IsIndustryGood = model.IsIndustryGood,
                Name           = model.Name,
                Status         = TemplateStatus.Draft,
                Version        = 1
            };

            // Create new schema
            _dataSchemaService.Create(newSchema, stream.ToArray(), model.UploadFile.FileName, LoggedInUser);

            // Setup status message
            Toastr.Success("Schema was successfully created");

            // Return result
            return(RedirectToAction("Index"));
        }
示例#6
0
        public ActionResult Edit(int id, SchemaModel model)
        {
            MemoryStream stream   = null;
            var          fileName = string.Empty;

            // Check whether file needs to be updated
            if (model.UploadFile != null)
            {
                // Setup file stream
                stream   = new MemoryStream();
                fileName = model.UploadFile.FileName;
                model.UploadFile.InputStream.CopyTo(stream);
            }

            // Setup internal model
            var data = new DataLinker.Models.SchemaModel
            {
                DataSchemaID   = id,
                Description    = model.Description,
                IsAggregate    = model.IsAggregate,
                IsIndustryGood = model.IsIndustryGood,
                Name           = model.Name,
                PublicId       = model.PublicId
            };

            // Update schema
            _dataSchemaService.Update(data, stream, fileName, LoggedInUser);

            // Setup status message
            Toastr.Success("Schema was successfully updated");

            // Return result
            return(RedirectToAction("Index"));
        }
示例#7
0
        public ActionResult EditProviderEndpoint(int id, int endpointId, ProviderEndpointModel model)
        {
            // Edit endpoint details
            ProviderEndpoint endpoint = _applications.EditEndpoint(id, endpointId, model, LoggedInUser);

            // Setup status
            Toastr.Success("Changes to endpoint were successfully saved.");

            // Return result
            return(RedirectToAction("Details", new { endpointId = endpoint.ApplicationId }));
        }
示例#8
0
        public ActionResult AddProviderEndpoint(int id, ProviderEndpointModel model)
        {
            // Add endpoint
            _applications.AddEndpoint(id, model, LoggedInUser);

            // Setup status message
            Toastr.Success("Provider endpoint was successfully created! You can add data agreement for this schema now.");

            // Return result
            return(RedirectToAction("Details", new { id }));
        }
示例#9
0
        public ActionResult Publish(int id, int schemaId, int appId)
        {
            // Publish license
            _licenseService.Publish(id, appId, schemaId, LoggedInUser);

            // Setup status message
            Toastr.Success("License was successfully published.");

            // Setup redirect url
            var redirectUrl = Url.Action("Index", "Licenses", new { appId, schemaId });

            // Return result
            return(Json(new { Url = redirectUrl }, JsonRequestBehavior.AllowGet));
        }
示例#10
0
        public ActionResult PublishSchema(int id)
        {
            // Publish schema
            DataSchema dataSchema = _dataSchemaService.Publish(id, LoggedInUser);

            // Setup redirect url
            var redirectUrl = Url.Action("Index");

            // Setup status message
            Toastr.Success($"Schema {dataSchema.Name} was successfully published.");

            // Return response
            return(Json(new { Url = redirectUrl }, JsonRequestBehavior.AllowGet));
        }
示例#11
0
        public async Task <ActionResult> Edit(int organizationId, int userId, UserModel model)
        {
            // Edit user details
            var data = (UserDetailsModel)model;

            data.Email = model.Email;
            string statusMsg = await _users.EditUserDetails(userId, data, LoggedInUser);

            // Setup status message
            Toastr.Success("Profile was successfully updated." + statusMsg);

            // Return result
            return(new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { isSuccess = true }
            });
        }
示例#12
0
        public ActionResult SendToLegalOfficer(int id, int schemaId, int appId)
        {
            // Send request
            _licenseService.RequestLicenseVerification(id, appId, schemaId, LoggedInUser);

            // Log user action
            _auditLog.Log(AuditStream.LegalAgreements, "Send to Legal", new { LoggedInUser.ID, LoggedInUser.Email },
                          new
            {
                remote_ip = Request.UserHostAddress,
                browser   = Request.Browser.Browser
            });

            // Redirect to provider licenses screen
            var redirectUrl = Url.Action("Index", "Licenses", new { appId, schemaId });

            Toastr.Success("License was sent to Legal Officer of your organization.");
            return(Json(new { Url = redirectUrl, isSuccess = true }, JsonRequestBehavior.AllowGet));
        }
示例#13
0
        public ActionResult Create(int appId, int schemaId, BuildLicenseModel model)
        {
            // Check whether posted data has selected sections
            if (model == null || !model.Sections.Any())
            {
                throw new BaseException("Invalid data.");
            }

            // Check whether it's a request for license preview
            if (Request.Form["preview"] != null)
            {
                // Get file result
                var result = _licenseFiles.GetTemplatedLicenseForPreview(model.Sections, LoggedInUser.Organization.ID, schemaId, LoggedInUser);

                // Setup stream
                var stream = new MemoryStream(result.Content);

                // Return file
                return(File(stream, result.MimeType, result.FileName));
            }

            // Setup default redirect url
            var redirectUrl = Url.Action("Index", "Licenses", new { appId, schemaId });

            // Check whether processing request for provider
            if (!model.IsProvider)
            {
                throw new BaseException("Only provider can create licenses");
            }

            _licenseService.CreateProviderTemplatedLicense(appId, schemaId, model, LoggedInUser);

            // Setup status message
            Toastr.Success("License for schema was successfully created.");

            // Return result
            return(Redirect(redirectUrl));
        }
示例#14
0
        private Task CreateNewTask(string type, string title, string description, Priority priority, DateTime due)
        {
            if (title.Length < 3)
            {
                Toastr.Warning("Warning", "Title length is too short");
                return(null);
            }
            if (description.Length < 10)
            {
                Toastr.Warning("Warning", "Description length is too short.");
                return(null);
            }
            if (!DateService.DateAfterToday(due))
            {
                Toastr.Warning("Warning", "The due date must be in the future.");
                return(null);
            }

            Task newTask = null;

            Toastr.TurnOffNotifications(); // Prevent multiple 'update' notifications

            DateTime now = DateTime.Now;

            switch (type)
            {
            case "Assignment":
                string subject    = tbxSubject.Text;
                int    percentage = int.Parse(tbxPercentage.Text);

                newTask = new AssignmentTask(title, description, priority, due, now, subject, percentage);
                break;

            case "Exam":
                string subjectExam    = tbxSubjectExam.Text;
                string materials      = tbxMaterials.Text;
                int    percentageExam = int.Parse(tbxPercentExam.Text);

                newTask = new ExamTask(title, description, priority, due, now, subjectExam, percentageExam, new List <string>(materials.Split(',')));
                break;

            case "Event":
                string location = tbxLocation.Text;

                newTask = new EventTask(title, description, priority, due, now, location);
                break;

            case "Payment":
                decimal amount = decimal.Parse(tbxAmount.Text);

                newTask = new PaymentTask(title, description, priority, due, now, amount);
                break;

            default:
                Toastr.Error("Error", "Invalid task type.");
                break;
            }

            Toastr.TurnOnNotifications();

            if (newTask != null)
            {
                Toastr.Success("Created", "The '" + title + "' task has been created");
            }

            return(newTask);
        }