Exemplo n.º 1
0
        public async Task <bool> Create(DonationView result)
        {
            var donation = new DonationModel
            {
                Quantity      = result.Bags,
                Institution   = await _context.Instituties.FindAsync(result.SelectedInstitutionId),
                Street        = result.Address,
                City          = result.City,
                ZipCode       = result.Postcode,
                PickUpDate    = result.Data,
                PickUpTime    = result.Time,
                PickUpComment = result.Moreinfo
            };

            foreach (var category in result.CategoriesSelected)
            {
                var toDb = new CategoryDonationModel
                {
                    Donation = donation,
                    Category = await _context.Categories.FindAsync(category)
                };
                _context.CategoryDonation.Add(toDb);
            }


            _context.Donations.Add(donation);
            return(await _context.SaveChangesAsync() > 0);
        }
        [HttpPut("{id}")] // PUT: api/candidates/5
        public async Task <IActionResult> PutCandidate(int id, Candidate candidate)
        {
            if (id != candidate.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        /// <summary>
        /// Akış:
        ///
        /// - HemOnline kullanıcısı sicil ve şifresiyle logini çağırır
        /// - Sistem cep telefonu bulamamışsa Hata döner
        ///		- Sonraki çağırımda cep telefonu ile gelir ve OTP oluşturularak tele gönderilir.
        ///	- Cep telefonu bulunmuşsa OTP oluşturularak tele gönderilir.
        ///
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public override async Task <LoginUserResult> Login(LoginUserCommand command)
        {
            var provider = new FrameworkLoginProvider(context);
            var result   = provider.CheckPassword(command.ExternalUserId, command.Password);
            var user     = result.Data;

            // Eger telefon numarasi verilmisse guncelle ve devam et
            if (command.IsPhoneValid)
            {
                // Eger esitse bosuna db'yi yorma.
                if (user.UpdateMobilePhone(command.MobilePhone))
                {
                    await context.SaveChangesAsync();
                }
            }
            if (result.Success)
            {
                if (command.IsPhoneValid)
                {
                    // Bu provider icin external id hemonline login name idir.
                    return(await PrepareOneTimePassword(Entities.Concrete.AuthenticationProviderType.Staff, user.MobilePhone, user.LoginName));
                }
                else
                {
                    return new LoginUserResult
                           {
                               Message      = "Bilgiler doğru. Cep telefonu gerekiyor.",
                               Status       = LoginUserResult.LoginStatus.PhoneNumberRequired,
                               MobilePhones = new string[] { user.MobilePhone }
                           }
                };
            }
            else
            {
                return new LoginUserResult {
                           Message = result.Message, Status = LoginUserResult.LoginStatus.WrongCredentials
                }
            };
        }
Exemplo n.º 4
0
 public async Task <bool> Create(InstitutionModel institution)
 {
     _context.Instituties.Add(institution);
     return(await _context.SaveChangesAsync() > 0);
 }
Exemplo n.º 5
0
 public async Task <bool> Create(CategoryModel category)
 {
     _context.Categories.Add(category);
     return(await _context.SaveChangesAsync() > 0);
 }