public Refferal getRefferalData()
        {
            Refferal refferal = new Refferal();

            refferal.Reffered_by = txtName.Text.ToString().Trim();
            refferal.Details     = txtDetails.Text.ToString().Trim();

            return(refferal);
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                //string userResponse = HttpContext.Request.Params["g-recaptcha-response"];
                //bool validCaptcha = ReCaptcha.ValidateCaptcha(userResponse);
                //if (!validCaptcha)
                //{
                //    ModelState.AddModelError("", "Captcha is wrong");
                //    return View(model);
                //}

                var user = new ApplicationUser()
                {
                    UserName = model.UserName
                };

                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInAsync(user, isPersistent : false);

                    if (!String.IsNullOrWhiteSpace(model.ReferralUsername))
                    {
                        var invitationSender = _context.Users.Where(u => u.UserName == model.ReferralUsername).SingleOrDefault();
                        if (invitationSender != null)
                        {
                            var refferal = new Refferal()
                            {
                                Activate = false, Id = user.Id, UserId = invitationSender.Id
                            };
                            _context.Refferals.Add(refferal);
                            _context.SaveChanges();
                        }
                    }
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    AddErrors(result);
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemple #3
0
        /// <summary>
        /// Method to Insert Patient Refferal
        /// </summary>
        /// <param name="refferal"></param>

        public static void Insert(Refferal refferal)
        {
            SqlParameter[] param = new SqlParameter[3];

            param[0]           = new SqlParameter("@referreal_id", SqlDbType.NVarChar, 15);
            param[0].Direction = ParameterDirection.Output;
            param[1]           = new SqlParameter("@reffered_by_name", refferal.Reffered_by);
            param[2]           = new SqlParameter("@details", refferal.Details);


            try
            {
                refferal.Refferal_id = DBHelper.ExecuteReturnIDStoredProcedure("insert_refferal", param);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #4
0
        public Task Handle(CreateRefferalCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.CompletedTask);
            }

            var Refferal = new Refferal(Guid.NewGuid(), message.UserId, message.UserRefId);

            _RefferalRepository.Add(Refferal);

            if (Commit())
            {
                Bus.RaiseEvent(new RefferalCreatedEvent(Refferal.Id, Refferal.UserId, Refferal.UserRefId));
            }

            return(Task.CompletedTask);
        }
Exemple #5
0
        public IActionResult AddRefferalToPatient([FromRoute] int patientId, [FromBody] RefferalCommand refferalCommand)
        {
            if (refferalCommand != null)
            {
                Card card = _context.Cards.Where(x => x.Patient.Id == patientId).FirstOrDefault();

                if (card != null)
                {
                    Refferal r = new Refferal
                    {
                        PatientId            = patientId,
                        DescriptionOfProblem = refferalCommand.DescriptionOfProblem,
                        DoctorName           = refferalCommand.DoctorName,
                        Note        = refferalCommand.Note,
                        RefferingMD = refferalCommand.RefferingMD,
                        Date        = refferalCommand.Date,
                    };

                    card.Refferals = new List <Refferal>
                    {
                        r
                    };

                    _context.SaveChanges();
                    return(Ok(new { message = "Succesfully added refferal to patient" }));
                }
                else
                {
                    return(BadRequest());
                }
            }
            else
            {
                return(BadRequest());
            }
        }