public async Task <IActionResult> Create(DoctorUser doctorUser)
        {
            Doctors doctors = new Doctors();

            if (ModelState.IsValid)
            {
                Users user = new Users();
                user.Name     = doctorUser.Name;
                user.Email    = doctorUser.Email;
                user.Password = Hashing.CalculateMD5Hash(doctorUser.Password);

                _context.Add(user);
                await _context.SaveChangesAsync();

                doctors.UserId             = user.Id;
                doctors.Specialization     = doctorUser.Specialization;
                doctors.RegistrationNumber = doctorUser.RegistrationNumber;
                doctors.Phone = doctorUser.Phone;

                _context.Add(doctors);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Email", doctors.UserId);
            return(View(doctors));
        }
        public async Task <IActionResult> PutClinics([FromRoute] int id, [FromBody] Clinics clinics)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != clinics.Id)
            {
                return(BadRequest());
            }

            _context.Entry(clinics).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClinicsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #3
0
        //public async Task<IActionResult> Create([Bind("Id,UserId,Nic,Address,Dob,BloodGroup,EmergencyContactName,EmergencyContactPhone,EmergencyContactAddress,Notes")] Patients patients, [Bind("Id,Name,Email,Password,ClinicId")] Users users)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        _context.Add(patients);
        //        await _context.SaveChangesAsync();
        //        return RedirectToAction(nameof(Index));
        //    }
        //    ViewData["UserId"] = new SelectList(_context.Users, "Id", "Email", patients.UserId);
        //    return View(patients);
        //}

        public async Task <IActionResult> Create(PatientUser patientUser)
        {
            Patients patient = new Patients();

            if (ModelState.IsValid)
            {
                Users user = new Users();
                user.Name     = patientUser.Name;
                user.Email    = patientUser.Email;
                user.Password = Hashing.CalculateMD5Hash(patientUser.Password);

                _context.Add(user);
                await _context.SaveChangesAsync();

                patient.UserId  = user.Id;
                patient.Address = patientUser.Address;
                patient.Dob     = patientUser.Dob;
                patient.Nic     = patientUser.Nic;

                _context.Add(patient);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Email", patient.UserId);
            return(View(patient));
        }
        public async Task <IActionResult> Create([Bind("Id,ClinicId,PatientId,DoctorId,SessionId,AppointedAt,IsPresent,CreatedBy,Diagnosis")] Appointments appointments)
        {
            if (ModelState.IsValid)
            {
                string user_id = HttpContext.Session.GetString("user_id");
                if (!string.IsNullOrEmpty(user_id))
                {
                    int created_by = int.Parse(user_id);
                    appointments.CreatedBy = created_by;
                }

                _context.Add(appointments);
                await _context.SaveChangesAsync();

                var payment = new Payments();
                payment.Amount        = 0;
                payment.AppointmentId = appointments.Id;
                payment.IsReceived    = 0;

                _context.Add(payment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClinicId"]  = new SelectList(_context.Clinics, "Id", "Address", appointments.ClinicId);
            ViewData["CreatedBy"] = new SelectList(_context.Users, "Id", "Email", appointments.CreatedBy);
            ViewData["DoctorId"]  = new SelectList(_context.Doctors, "Id", "Phone", appointments.DoctorId);
            ViewData["PatientId"] = new SelectList(_context.Patients, "Id", "Address", appointments.PatientId);
            ViewData["SessionId"] = new SelectList(_context.Sessions, "Id", "Id", appointments.SessionId);
            return(View(appointments));
        }
        public async Task <IActionResult> Create([Bind("Id,Name")] RoleGroups roleGroups)
        {
            if (ModelState.IsValid)
            {
                _context.Add(roleGroups);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(roleGroups));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,RegNo,Address,Phone,Email,SubscribedAt,BillingCycle,IsActive")] Clinics clinics)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clinics);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(clinics));
        }
        public async Task <IActionResult> Create([Bind("Id,ClinicId,Amount,IssuedAt,PaidAt")] SubscriptionInvoices subscriptionInvoices)
        {
            if (ModelState.IsValid)
            {
                _context.Add(subscriptionInvoices);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClinicId"] = new SelectList(_context.Clinics, "Id", "Name", subscriptionInvoices.ClinicId);
            return(View(subscriptionInvoices));
        }
        public async Task <IActionResult> Create([Bind("Id,AppointmentId,Description,Amount,PaidAt,IsReceived,Method")] Payments payments)
        {
            if (ModelState.IsValid)
            {
                _context.Add(payments);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AppointmentId"] = new SelectList(_context.Appointments, "Id", "Id", payments.AppointmentId);
            return(View(payments));
        }
Exemple #9
0
        public async Task <IActionResult> Create([Bind("Id,UserId,RoleGroupId")] UserRoleGroups userRoleGroups)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userRoleGroups);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoleGroupId"] = new SelectList(_context.RoleGroups, "Id", "Name", userRoleGroups.RoleGroupId);
            ViewData["UserId"]      = new SelectList(_context.Users, "Id", "Name", userRoleGroups.UserId);
            return(View(userRoleGroups));
        }
Exemple #10
0
        public async Task <IActionResult> Create([Bind("Id,AppointmentId,InventoryId,Quantity,Dosage,Notes,IssuedAt,IsPublic")] Prescriptions prescriptions)
        {
            if (ModelState.IsValid)
            {
                _context.Add(prescriptions);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AppointmentId"] = new SelectList(_context.Appointments, "Id", "Id", prescriptions.AppointmentId);
            ViewData["InventoryId"]   = new SelectList(_context.Inventories, "Id", "BrandName", prescriptions.InventoryId);
            return(View(prescriptions));
        }
        public async Task <IActionResult> Create([Bind("Id,ClinicId,DoctorId,Start,Stop,HasConducted,Fee")] Sessions sessions)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sessions);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClinicId"] = new SelectList(_context.Clinics, "Id", "Address", sessions.ClinicId);
            ViewData["DoctorId"] = new SelectList(_context.Doctors, "Id", "Phone", sessions.DoctorId);
            return(View(sessions));
        }
Exemple #12
0
        public async Task <IActionResult> Create([Bind("Id,RoleGroupId,RoleId")] RoleCarryOuts roleCarryOuts)
        {
            if (ModelState.IsValid)
            {
                _context.Add(roleCarryOuts);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoleId"]      = new SelectList(_context.Roles, "Id", "Description", roleCarryOuts.RoleId);
            ViewData["RoleGroupId"] = new SelectList(_context.RoleGroups, "Id", "Name", roleCarryOuts.RoleGroupId);
            return(View(roleCarryOuts));
        }
        public async Task <IActionResult> Create([Bind("Id,ClinicId,DoctorId,Amount,PayedAt")] Settlements settlements)
        {
            if (ModelState.IsValid)
            {
                _context.Add(settlements);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClinicId"] = new SelectList(_context.Clinics, "Id", "Address", settlements.ClinicId);
            ViewData["DoctorId"] = new SelectList(_context.Doctors, "Id", "Phone", settlements.DoctorId);
            return(View(settlements));
        }
        public async Task <IActionResult> Create([Bind("Id,ClinicId,PatientId,DoctorId,SessionId,AppointedAt,IsPresent,CreatedBy,Diagnosis")] Appointments appointments)
        {
            if (ModelState.IsValid)
            {
                _context.Add(appointments);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClinicId"]  = new SelectList(_context.Clinics, "Id", "Address", appointments.ClinicId);
            ViewData["CreatedBy"] = new SelectList(_context.Users, "Id", "Email", appointments.CreatedBy);
            ViewData["DoctorId"]  = new SelectList(_context.Doctors, "Id", "Phone", appointments.DoctorId);
            ViewData["PatientId"] = new SelectList(_context.Patients, "Id", "Address", appointments.PatientId);
            ViewData["SessionId"] = new SelectList(_context.Sessions, "Id", "Id", appointments.SessionId);
            return(View(appointments));
        }
        public async Task <IActionResult> PutUsers([FromRoute] int id, [FromBody] Users users)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Entry(users).State = EntityState.Modified;

            if (id != users.Id)
            {
                return(BadRequest());
            }

            string currentPassword = _context.Users.Find(id).Password;

            if (users.Password == null)
            {
                users.Password = currentPassword;
            }


            users.Password = Hashing.CalculateMD5Hash(users.Password);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UsersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Email,Password,ClinicId")] Users users)
        {
            users.Password = Hashing.CalculateMD5Hash(users.Password);
            if (ModelState.IsValid)
            {
                var curUser = _context.Users.SingleOrDefault(u => u.Email == users.Email);
                if (curUser != null)
                {
                    return(Ok("Email already exist" +
                              ""));
                }

                _context.Add(users);
                await _context.SaveChangesAsync();

                await this.SendEmailAsync(users.Email, "Successfully Registered", "Hi! This is to inform you that your registration was successfull at Medecs");

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClinicId"] = new SelectList(_context.Clinics, "Id", "Address", users.ClinicId);
            return(View(users));
        }
Exemple #17
0
        public async Task <IActionResult> Create([Bind("Id,ClinicId,AddedBy,GenericName,BrandName,ExpiryDate,StorageTemperature,Manufacturer,Strength,Quantity,UnitPrice,BatchNo,ReorderLevel,ManufacturedDate,Notes")] Inventories inventories)
        {
            if (ModelState.IsValid)
            {
                string user_id = HttpContext.Session.GetString("user_id");

                if (!string.IsNullOrEmpty(user_id))
                {
                    int user_id_int = int.Parse(user_id);
                    inventories.AddedBy = user_id_int;
                    var user = _context.Users.FirstOrDefault(u => u.Id == user_id_int);
                    inventories.ClinicId = user.ClinicId;
                }

                _context.Add(inventories);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AddedBy"]  = new SelectList(_context.Users, "Id", "Email", inventories.AddedBy);
            ViewData["ClinicId"] = new SelectList(_context.Clinics, "Id", "Address", inventories.ClinicId);
            return(View(inventories));
        }
        public async Task <IActionResult> Index(string stripeEmail, string stripeToken, int payment_id)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var customers = new CustomerService();
            var charges   = new ChargeService();

            var customer = customers.Create(new CustomerCreateOptions
            {
                Email       = stripeEmail,
                SourceToken = stripeToken
            });

            Payments payments = _context.Payments.Find(payment_id);

            long amount = (long)(payments.Amount * 100);

            var charge = charges.Create(new ChargeCreateOptions
            {
                Amount      = amount,
                Description = "Medical Fee",
                Currency    = "lkr",
                CustomerId  = customer.Id
            });

            if (charge.Paid)
            {
                payments.IsReceived = 1;
                payments.Method     = "card";
            }


            //var payment = _context.Payments.Where(i => i.Id == Payments.Id).First();
            //payment.IsReceived = 1;
            //_context.SaveChanges();

            //_context.Attach(Payments).State = EntityState.Modified;

            _context.Attach(payments).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PaymentsExists(Payments.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(LocalRedirect("/Payments/Details?id=" + payments.Id.ToString()));

            //return RedirectToRoute("/Payment/Details?id=" + payments.Id.ToString());

            //return RedirectToPage("/Payment/Details?id="+payments.Id.ToString());
        }