Inheritance: BaseDto
コード例 #1
0
        public bool AddPhone(PhoneDto dto)
        {
            if (!this.db.Phones.Any(x => x.DeletedOn.HasValue == false && x.Telephone.Trim() == dto.Telephone.Trim()))
            {
                this.db.Phones.Add(new Phone
                {
                    CreatedOn = DateTime.Now,
                    UpdatedOn = DateTime.Now,
                    UpdatedBy = dto.User.Id,
                    IsFax = dto.IsFax,
                    IsPrimary = dto.IsPrimary,
                    Comment = dto.Comment,
                    Telephone = dto.Telephone.Trim(),
                    UserId = dto.User.Id
                });
                return true;
            }

            return false;
        }
 public bool AddPhone(PhoneDto dto)
 {
     throw new NotImplementedException();
 }
コード例 #3
0
        public bool UpdatePhone(PhoneDto dto)
        {
            var phone = this.db.Phones.FirstOrDefault(x => x.DeletedOn.HasValue == false && x.UserId == dto.User.Id && x.Telephone.Trim() == dto.Telephone.Trim());

            if (phone != null)
            {
                phone.Telephone = dto.Telephone;
                phone.IsFax = dto.IsFax;
                phone.IsPrimary = dto.IsPrimary;
                phone.UpdatedBy = dto.UpdatedBy;
                phone.Comment = dto.Comment;
                phone.UpdatedOn = DateTime.Now;
                phone.UpdatedBy = dto.UpdatedBy;

                this.db.SaveChanges();

                return true;
            }

            return false;
        }