public Email MapAndSaveEmailModelDCToEmail(Email a, EmailModelDC b)
 {
     a.EmailId      = b.emailId;
     a.EmailAddress = b.emailAddress;
     a.IsPrimary    = b.isPrimary;
     a.UserId       = b.userId;
     a.IsDeleted    = b.isDeleted;
     return(a);
 }
 public EmailModelDC MapAndSaveEmailToEmailModelDC(EmailModelDC a, Email b)
 {
     a.emailId      = b.EmailId;
     a.emailAddress = b.EmailAddress;
     a.isPrimary    = b.IsPrimary;
     a.userId       = b.UserId;
     a.isDeleted    = b.IsDeleted;
     return(a);
 }
        public void AddEmail(EmailModelDC obj)
        {
            if (obj == null)
            {
                throw new ArgumentException(Messages.EmailExceptionAdd);
            }

            _db.Emails.Add(MapToEmail(obj));
            _db.SaveChanges();
        }
 public void AddEmail(EmailModelDC obj)
 {
     foreach (EmailModelDC email in _emails.GetEmails())
     {
         if (email.emailId == obj.emailId)
         {
             throw new ArgumentException(Messages.EmailExceptionAdd);
         }
     }
     this._emails.AddEmail(obj);
 }
 public Email MapToEmail(EmailModelDC a)
 {
     return(new Email()
     {
         EmailId = a.emailId,
         EmailAddress = a.emailAddress,
         IsPrimary = a.isPrimary,
         UserId = a.userId,
         IsDeleted = a.isDeleted
     });
 }
        public void UpdateEmail(int id, EmailModelDC obj)
        {
            Email email = _db.Emails.FirstOrDefault(x => x.EmailId == id);

            if (email == null)
            {
                throw new ArgumentException(Messages.EmailExceptionUpdateById);
            }

            email = MapAndSaveEmailModelDCToEmail(email, obj);
            _db.SaveChanges();
        }
        public void UpdateEmail(int id, EmailModelDC obj)
        {
            if (id < 0)
            {
                throw new ArgumentException(Messages.EmailExceptionUpdateById);
            }

            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            _emails.UpdateEmail(id, obj);
        }
 // PUT: api/Email/5
 public void Put(int id, [FromBody] EmailModelDC email)
 {
     emailMethods.UpdateEmail(id, email);
 }
 // POST: api/Email
 public void Post([FromBody] EmailModelDC email)
 {
     emailMethods.AddEmail(email);
 }