Ejemplo n.º 1
0
        public async Task CreateAsync_WithIncorectData_ShouldThrowException(string fullName, int age, string aboGroup, string rhesusFactor, int city)
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var seeder  = new Seeder();
            await seeder.SeedUsersAsync(context);

            await seeder.SeedBloodTypesAsync(context);

            await seeder.SeedCities(context);

            var userManager  = this.GetUserManagerMock(context);
            var donorService = new DonorService(context, userManager.Object);

            var donorServiceModel = new DonorServiceModel
            {
                FullName  = fullName,
                Age       = age,
                BloodType = new BloodDonationSystem.Services.Models.BloodTypeServiceModel
                {
                    ABOGroupName = aboGroup,
                    RhesusFactor = rhesusFactor,
                },
                UserId = context.Users.First().Id,
                CityId = city,
            };

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await donorService.CreateAsync(donorServiceModel);
            });
        }
Ejemplo n.º 2
0
 public EmployeeController(EmployeeService employeeService, DoctorsService doctorService, DonorService donorService, IEmailSender _emailSender, Broadcaster broadcaster)
 {
     this.employeeService = employeeService;
     this.doctorService   = doctorService;
     this.broadcaster     = broadcaster;
     this._emailSender    = _emailSender;
     this.donorService    = donorService;
 }
Ejemplo n.º 3
0
        public static DonorService CreateService(ICollection <Donor> data = null, MockDataContext context = null)
        {
            context = context ?? new MockDataContext();
            var service = new DonorService(context);

            context.MockDonors.SetupData(data, ids => context.Donors.SingleOrDefault(a => a.Id == ids[0].ToString()));

            return(service);
        }
Ejemplo n.º 4
0
        public ActionResult Edit(int?id)
        {
            var donorService = new DonorService(db);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BloodDonor donor = db.BloodDonors.Find(id);

            if (donor == null)
            {
                return(HttpNotFound());
            }
            var blood = db.ConfigMasters.FirstOrDefault(s => s.ConfigShortName == "bloodgroup").ConfigId;

            ViewBag.bloodGroups = db.ConfigValueSets.Where(b => b.ConfigValueSetId == blood).Select(s => new VmSelectList {
                Id = s.ConfigValueId, Name = s.ConfigValue
            });

            var gender = db.ConfigMasters.FirstOrDefault(s => s.ConfigShortName == "gender").ConfigId;

            ViewBag.gendertypes = db.ConfigValueSets.Where(g => g.ConfigValueSetId == gender).Select(s => new VmSelectList {
                Id = s.ConfigValueId, Name = s.ConfigValue
            });

            ViewBag.DivisionList = db.Division.Select(s => new VmSelectList {
                Id = s.DivisionHeaderId, Name = s.DivisionName
            });

            ViewBag.DistrictList = db.District.Select(s => new VmDistrict {
                DistrictHeaderId = s.DistrictHeaderId, DistrictName = s.DistrictName, DivisionHeaderId = s.DivisionHeaderId
            });

            ViewBag.ThanaList = db.Upazila.Select(s => new VmUpazilla {
                ThanaHeaderId = s.UpazilaHeaderId, ThanaName = s.UpazilaName, DistrictHeaderId = s.DistrictHeaderId
            });
            var VmDonorAdd = new VmDonorAdd();

            VmDonorAdd.BloodDonorHeaderId = id ?? 0;
            VmDonorAdd.BloodDonorName     = donor.BloodDonorName;
            VmDonorAdd.Email       = donor.Email;
            VmDonorAdd.MobileNo    = donor.MobileNo;
            VmDonorAdd.PhoneNo     = donor.PhoneNo;
            VmDonorAdd.Bloodgroup  = donor.Bloodgroup;
            VmDonorAdd.Gender      = donor.Gender;
            VmDonorAdd.Division    = donor.Division;
            VmDonorAdd.District    = donor.District;
            VmDonorAdd.Thana       = donor.Thana;
            VmDonorAdd.DOB         = donor.DOB.ToString("dd/MM/yyyy");
            VmDonorAdd.Occupation  = donor.Occupation;
            VmDonorAdd.FbUrl       = donor.FbUrl;
            VmDonorAdd.LastDonated = donor.LastDonated != null?donor.LastDonated.Value.ToString("dd/MM/yyyy") : "";

            VmDonorAdd.ReadyForDonate = donor.ReadyForDonate;
            return(View(VmDonorAdd));
        }
Ejemplo n.º 5
0
 public SetupCommand(IServiceProvider services, DonorService donor,
                     PartnerManagerService partners, GuildBanService ban,
                     DiscordRestClient rest)
 {
     this._services = services;
     this._donor    = donor;
     this._partners = partners;
     this._ban      = ban;
     this._rest     = rest;
 }
Ejemplo n.º 6
0
        public async Task GetByUserIdAsync_ShouldReturn_CorectDonor()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var seeder  = new Seeder();
            await seeder.SeedDonorAsync(context);

            var userManager  = this.GetUserManagerMock(context);
            var donorService = new DonorService(context, userManager.Object);

            var actualResult = await donorService.GetByUserIdAsync("userId1");

            Assert.True(actualResult.UserId == "userId1");
        }
Ejemplo n.º 7
0
        public async Task GetByUserIdAsync_ShouldThrownException_WithInvalidUser()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var seeder  = new Seeder();
            await seeder.SeedDonorAsync(context);

            var userManager  = this.GetUserManagerMock(context);
            var donorService = new DonorService(context, userManager.Object);

            await Assert.ThrowsAsync <InvalidOperationException>(async() =>
            {
                await donorService.GetByUserIdAsync("invalidId");
            });
        }
Ejemplo n.º 8
0
        public async Task All_ShouldReturnCorectData()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var seeder  = new Seeder();
            await seeder.SeedDonorAsync(context);

            var userManager  = this.GetUserManagerMock(context);
            var donorService = new DonorService(context, userManager.Object);

            var actualResult   = donorService.All().Result;
            var expectedResult = context.Donors;

            Assert.True(actualResult.Count() == expectedResult.Count());
            Assert.IsAssignableFrom <IQueryable <DonorServiceModel> >(actualResult);
        }
Ejemplo n.º 9
0
        public async System.Threading.Tasks.Task <ActionResult> Add(VmDonorAdd model)
        {
            if (ModelState.IsValid)
            {
                #region Image Upload
                var uri = Request.Url.Host;
                System.IO.Directory.CreateDirectory(Server.MapPath("~/Images/ProfilePic/" + uri));
                string path = "";
                if (model.ProPic != null)
                {
                    string pic          = System.IO.Path.GetFileName(model.ProPic.FileName);
                    string physicalPath =
                        System.IO.Path.Combine(Server.MapPath("~/Images/ProfilePic/" + uri), pic);
                    path = "/Images/ProfilePic/" + uri + "/" + pic;
                    model.ProPic.SaveAs(physicalPath);
                    model.ImageUrl = path;
                }
                #endregion
                model.DOB         = DateTimeHelperService.ConvertBDDateStringToDateTimeObject(model.DOB);
                model.LastDonated = !string.IsNullOrEmpty(model.LastDonated) ?DateTimeHelperService.ConvertBDDateStringToDateTimeObject(model.LastDonated):null;
                var donorService  = new DonorService(db);
                int donorHeaderId = 0;
                donorService.Add(model, out donorHeaderId);
                if (model.BloodDonorHeaderId == 0 && model.Password == model.ConfirmPassword)
                {
                    var user = new ApplicationUser {
                        UserName = model.Email, Email = model.Email, UserType = (int)UserType.Donor, ReferrenceId = donorHeaderId, CreationDate = DateTime.Now, LastUpdateDate = DateTime.Now
                    };
                    var result = await UserManager.CreateAsync(user, model.Password);

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

                        // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                        // Send an email with this link
                        // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                        // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                        // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
        public static void Main(string[] args)
        {
            ICaseRepository      caseRepository      = new CaseDbRepository();
            IDonorRepository     donorRepository     = new DonorDbRepository();
            IVolunteerRepository volunteerRepository = new VolunteerDbRepository();
            IDonationRepository  donationRepository  = new DonationDbRepository();

            CaseService      caseService      = new CaseService(caseRepository);
            DonorService     donorService     = new DonorService(donorRepository);
            VolunteerService volunteerService = new VolunteerService(volunteerRepository);
            DonationService  donationService  = new DonationService(donationRepository);

            IService serverService = new ServerService(caseService, donorService, volunteerService, donationService);

            SerialConcurrentServer server = new SerialConcurrentServer("127.0.0.1", 55555, serverService);

            server.Start();
        }
Ejemplo n.º 11
0
        public async Task CreateAsync_WithCorectData_ShouldReturnCorectResult(string fullName, int age, string aboGroup, string rhesusFactor, int city)
        {
            var errorMessage = "DonorService CreateAsync method does not return properly ";

            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var seeder  = new Seeder();
            await seeder.SeedUsersAsync(context);

            await seeder.SeedBloodTypesAsync(context);

            await seeder.SeedCities(context);

            var userManager  = this.GetUserManagerMock(context);
            var donorService = new DonorService(context, userManager.Object);

            var donorServiceModel = new DonorServiceModel
            {
                FullName  = fullName,
                Age       = age,
                BloodType = new BloodDonationSystem.Services.Models.BloodTypeServiceModel
                {
                    ABOGroupName = aboGroup,
                    RhesusFactor = rhesusFactor,
                },
                UserId = context.Users.First().Id,
                CityId = city,
            };

            var result = await donorService.CreateAsync(donorServiceModel);

            var actualResult   = context.Donors.FirstOrDefault();
            var expectedResult = donorServiceModel;

            Assert.True(result);
            Assert.True(actualResult.FullName == expectedResult.FullName, errorMessage + "FullName");
            Assert.True(actualResult.Age == expectedResult.Age, errorMessage + "Age");
            Assert.True(actualResult.BloodType.ABOGroupName.ToString() == expectedResult.BloodType.ABOGroupName.ToString(), errorMessage + "ABOGroup");
            Assert.True(actualResult.BloodType.RhesusFactor.ToString() == expectedResult.BloodType.RhesusFactor.ToString(), errorMessage + "RhesusFactor");
            Assert.True(actualResult.UserId == expectedResult.UserId, errorMessage + "UserId");
            Assert.True(actualResult.CityId == expectedResult.CityId, errorMessage + "CityId");
        }
Ejemplo n.º 12
0
 public AccountController(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     IEmailSender emailSender,
     ILogger <AccountController> logger,
     DoctorsService doctorsService,
     DonorService donorService,
     AdminService adminService,
     EmployeeService employeeService,
     Broadcaster broadcaster)
 {
     _userManager     = userManager;
     _signInManager   = signInManager;
     _emailSender     = emailSender;
     _logger          = logger;
     _doctorsService  = doctorsService;
     _adminService    = adminService;
     _donorsService   = donorService;
     _employeeService = employeeService;
     _broadcaster     = broadcaster;
 }
 public DonorController()
 {
     donorService       = new DonorService(new HomeworkHotlineEntities());
     donorGivingService = new DonorGivingService(new HomeworkHotlineEntities());
 }
Ejemplo n.º 14
0
 public DonorController(DonorService donorService, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager)
 {
     this.donorService = donorService;
     this.userManager  = userManager;
     this.roleManager  = roleManager;
 }
Ejemplo n.º 15
0
 /// <inheritdoc />
 public DeliveryReceiptController(DonorService donorService)
 {
     _donorService = donorService;
 }
Ejemplo n.º 16
0
        private void AdminHome_Load(object sender, EventArgs e)
        {
            DonorService donorService = new DonorService();

            UserListDataGridView.DataSource = donorService.GetAllDonors();
        }
 public DonorsController()
 {
     _service = new DonorService();
     _collectionCenterService = new CollectionCenterService();
 }