Beispiel #1
0
        public async Task <IActionResult> PutContactInfoDAO(long id, ContactInfoRequest contactInfoRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (!ContactInfoDAOExists(id))
            {
                return(NotFound());
            }

            ContactInfoDAO contactInfoDAO = await _context.ContactInfoDAO.FindAsync(id);

            ContactInfoConverter.RequestToExistingDAO(contactInfoRequest, contactInfoDAO);
            _context.Entry(contactInfoDAO).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(StatusCode(500));
            }

            return(NoContent());
        }
        /*
         * 1 Successfull
         * 2 Invalid User
         * 3 E-mail Address not found
         * 4 Unable to send E-mail - contact administrator
         * 5 E-mail successfully sent
         */
        public int forgotPassword(string userName,string message)
        {
            string newPassword = System.Web.Security.Membership.GeneratePassword(8, 2);
            int flag = 2;//Invalid user

            AccountDAO acc_context = new AccountDAO();
            ContactInfoDAO con_context = new ContactInfoDAO();

            if (acc_context.isFound(userName))
            {
                if (con_context.isFound(userName, "e-mail"))
                {
                    ContactInfoDTO email = con_context.find(userName, "e-mail");
                    AccountDTO account = acc_context.find(userName);
                    account.password = newPassword;
                    acc_context.merge(account);

                    message.Replace("PASSWORD", newPassword);
                    flag = sendMail(email.data, message);

                }
                else
                {
                    flag = 3; //Email Address not found
                }

            }
            return flag;
        }
Beispiel #3
0
 public static void RequestToExistingDAO(ContactInfoRequest request, ContactInfoDAO dao)
 {
     dao.Email        = request.Email;
     dao.Name         = request.Name;
     dao.Telephone    = request.Telephone;
     dao.TelephoneAlt = request.TelephoneAlt;
     dao.Street       = request.Street;
     dao.City         = request.City;
     dao.Country      = request.Country;
     dao.PostalCode   = request.PostalCode;
 }
 public void doDelete()
 {
     if (isMinimumValid())
     {
         ContactInfoDAO contactDao = new ContactInfoDAO();
         contactDao.removeByUserId(view.getUsername(), view.getContactType());
         view.pageReload();
     }
     else
     {
         view.showFeedback("Error Field vlaues are not valid");
     }
 }
Beispiel #5
0
        public async Task <ActionResult <ContactInfoDAO> > PostContactInfoDAO(ContactInfoRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            ContactInfoDAO contactInfoDAO = ContactInfoConverter.RequestToDAO(request);

            _context.ContactInfoDAO.Add(contactInfoDAO);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetContactInfoDAO", new { id = contactInfoDAO.ContactInfoId }, contactInfoDAO));
        }
 public void doReset()
 {
     if (isMinimumValid())
     {
         ContactInfoDAO contactDao = new ContactInfoDAO();
         ContactInfoDTO contactInfoDto = contactDao.find(view.getUsername(), view.getContactType());
         setContactDto(contactInfoDto);
         view.showFeedback("Fields are reset.");
     }
     else
     {
         view.showFeedback("Error Field vlaues are not valid");
     }
 }
        public List<ContactInfoDTO> getUserContacts(string username)
        {
            List<ContactInfoDTO> contactDtoList = new List<ContactInfoDTO>();
            ContactInfoDAO contactDao = new ContactInfoDAO();
            List<ContactInfoDTO> contactList = contactDao.findAll();

            foreach (ContactInfoDTO contact in contactList)
            {
                if (contact.userName.Equals(username))
                {
                    contactDtoList.Add(contact);
                }
            }
            return contactDtoList;
        }
Beispiel #8
0
        public static ContactInfoDAO RequestToDAO(ContactInfoRequest request)
        {
            ContactInfoDAO data = new ContactInfoDAO();

            data.Name      = request.Name;
            data.Email     = request.Email;
            data.Telephone = request.Telephone;
            if (request.TelephoneAlt != null)
            {
                data.TelephoneAlt = request.TelephoneAlt;
            }
            data.Street     = request.Street;
            data.City       = request.City;
            data.Country    = request.Country;
            data.PostalCode = request.PostalCode;

            return(data);
        }
        public void ContactInfo_Test()
        {
            /*Context*/
            ContactInfoDAO contactInfo_context = new ContactInfoDAO();
            AccountDAO acc_context = new AccountDAO();
            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            ContactInfoDTO contact = new ContactInfoDTO();
            contact.userName = "******";
            contact.contactType = "skype";
            contact.data = "skippy";

            contactInfo_context.presist(contact);

            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = contactInfo_context.isFound("griddy", "skype");
            Assert.AreEqual(expected, actual);

            /*Update*/
            contact.data = "Gready";
            contactInfo_context.merge(contact);

            string expectedUpdate = "Gready";
            ContactInfoDTO contUpd = contactInfo_context.find("griddy", "skype");
            Assert.AreEqual(expectedUpdate, contUpd.data);

            /*Delete*/
            contactInfo_context.removeByUserId("griddy", "skype");

            bool expectedDelete = false;
            bool actualDelete = contactInfo_context.isFound("griddy", "skype");
            Assert.AreEqual(expectedDelete, actualDelete);

            acc_context.removeByUserId("griddy");
        }
Beispiel #10
0
        public static ContactInfoResponse DAOToResponse(ContactInfoDAO data)
        {
            ContactInfoResponse response = new ContactInfoResponse();

            response.ContactInfoId = data.ContactInfoId;
            response.Email         = data.Email;
            response.Name          = data.Name;
            response.Telephone     = data.Telephone;
            if (data.TelephoneAlt != null)
            {
                response.TelephoneAlt = data.TelephoneAlt;
            }
            response.Street     = data.Street;
            response.City       = data.City;
            response.Country    = data.Country;
            response.PostalCode = data.PostalCode;

            return(response);
        }
 public void doSave()
 {
     AccountService accountService = new AccountServiceImpl();
     if (isValid())
     {
         if (accountService.isUniqueContact(view.getUsername(), view.getContactType()))
         {
             ContactInfoDAO contactDao = new ContactInfoDAO();
             contactDao.presist(getContactInformationDto());
             view.pageReload();
         }
         else
         {
             view.setContactTypeError("Error, this address type is already used. Enter another value");
         }
     }
     else
     {
         view.showFeedback("Error Field vlaues are not valid");
     }
 }
        protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
        {
            // Determine the currently logged on user's UserId
            //MembershipUser currentUser = Membership.GetUser();
            //Guid currentUserId = (Guid)currentUser.ProviderUserKey;

            //Create user in Account table
            DAO_Account_Interface acc_ctx = new AccountDAO();
            AccountDTO newAccount = new AccountDTO();

            newAccount.userName = CreateUserWizard1.UserName.ToLower();
            newAccount.password = "******";
            newAccount.status = "active";
            newAccount.accountType = "user";
            acc_ctx.presist(newAccount);

            //Add User Email to COntact Info
            DAO_ContactInfo_Interface info_ctx = new ContactInfoDAO();
            ContactInfoDTO mail_info = new ContactInfoDTO();
            mail_info.userName = newAccount.userName;
            mail_info.contactType = "e-mail";
            mail_info.data = CreateUserWizard1.Email;
            info_ctx.presist(mail_info);

            //Add User information to User Table
            DAO_User_Interface user_ctx = new UserDAO();
            UserDTO user_info = new UserDTO();
            user_info.userName = newAccount.userName;
            user_info.id = txtID.Text;
            user_info.fullName = txtName.Text;
            user_info.surname = txtSurname.Text;
            user_info.nickName = txtNickname.Text;
            user_info.idType = RadioIdType.SelectedValue;
            user_info.race = RadioRace.SelectedValue;
            user_info.gender = RadioGender.SelectedValue;
            user_ctx.presist(user_info);

            Roles.AddUserToRole(newAccount.userName, "User");
        }
 public void doUpdate()
 {
     if (isValid())
     {
         ContactInfoDAO contactInfoDao = new ContactInfoDAO();
         contactInfoDao.merge(getContactInformationDto());
         view.showFeedback("Successfully updated");
     }
     else
     {
         view.showFeedback("Error Field vlaues are not valid");
     }
 }
        protected void rptContact_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            ContactInfoDTO contactDto;
            ContactInfoDAO contactDao = new ContactInfoDAO();
            String element = e.CommandName.ToString();

            if (element.Equals("contactType"))
            {
                contactDto = contactDao.find(getUsername(), e.CommandArgument.ToString());
                presenter.setContactDto(contactDto);
                presenter.updateView();
            }
        }
 public bool isUniqueContact(String username, String contactType)
 {
     bool isUnique = false;
     ContactInfoDAO contactDao = new ContactInfoDAO();
     try
     {
         return (!contactDao.isFound(username, contactType));
     }
     catch (InvalidOperationException ioe)
     {
         isUnique = true;
     }
     return isUnique;
 }