public TelephoneDirectoryRecordDTO FindRecordDetails(string phoneNumber)
        {
            TelephoneDirectoryRecord    objTelephoneRecordModel = objTelephone.FindRecordDetails(phoneNumber);
            TelephoneDirectoryRecordDTO objTelephoneRecordDto   = ModelToDtoMapping(objTelephoneRecordModel);

            return(objTelephoneRecordDto);
        }
예제 #2
0
        //method which maps viewmodel object to dto object
        public TelephoneDirectoryRecordDTO ModelToDtoMapping(TelephoneDirectoryRecordModel objTelephoneModel)
        {
            TelephoneDirectoryRecordDTO objTelephoneDto = new TelephoneDirectoryRecordDTO
            {
                FirstName   = objTelephoneModel.FirstName,
                LastName    = objTelephoneModel.LastName,
                Address     = objTelephoneModel.Address,
                PhoneType   = objTelephoneModel.PhoneType,
                PhoneNumber = objTelephoneModel.PhoneNumber
            };

            return(objTelephoneDto);
        }
예제 #3
0
        //method which maps dto object to viewmodel object
        public TelephoneDirectoryRecordModel DtoToModelMapping(TelephoneDirectoryRecordDTO objTelephoneDto)
        {
            TelephoneDirectoryRecordModel objTelephoneModel = new TelephoneDirectoryRecordModel
            {
                FirstName   = objTelephoneDto.FirstName,
                LastName    = objTelephoneDto.LastName,
                Address     = objTelephoneDto.Address,
                PhoneType   = objTelephoneDto.PhoneType,
                PhoneNumber = objTelephoneDto.PhoneNumber
            };

            return(objTelephoneModel);
        }
예제 #4
0
        public ActionResult Details(string phoneNumber)
        {
            if (phoneNumber == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //getting the details record of the specified phone number
            TelephoneDirectoryRecordDTO record = objTelephone.FindRecordDetails(phoneNumber);

            //mapping dto object to view model type
            TelephoneDirectoryRecordModel objTelephoneRecordViewModel = objConversion.DtoToModelMapping(record);

            if (record == null)
            {
                return(HttpNotFound());
            }
            return(View(objTelephoneRecordViewModel));
        }
예제 #5
0
 public ActionResult Create(TelephoneDirectoryRecordModel objTelephoneViewModel)
 {
     if (ModelState.IsValid)
     {
         //mapping view model object to dto type
         TelephoneDirectoryRecordDTO objTelephoneDto = objConversion.ModelToDtoMapping(objTelephoneViewModel);
         //check for duplicate entry of phone number to ensure uniqueness
         if (objTelephone.CheckDuplicate(objTelephoneDto.PhoneNumber, objTelephoneDto.PhoneType))
         {
             ModelState.AddModelError("PhoneNumber", "This phone number already exists");
             return(View(objTelephoneViewModel));
         }
         //method to create new record
         objTelephone.CreateRecord(objTelephoneDto);
         return(RedirectToAction("Index"));
     }
     return(View(objTelephoneViewModel));
 }
예제 #6
0
 public ActionResult Edit(TelephoneDirectoryRecordModel objTelephoneViewModel)
 {
     if (ModelState.IsValid)
     {
         TelephoneDirectoryRecordDTO objTelephoneDto = objConversion.ModelToDtoMapping(objTelephoneViewModel);
         //Checking for duplication only if phone number is changed
         if (phoneNumberOld != objTelephoneDto.PhoneNumber)
         {
             if (objTelephone.CheckDuplicate(objTelephoneDto.PhoneNumber, objTelephoneDto.PhoneType))
             {
                 ModelState.AddModelError("PhoneNumber", "This phone number already exists");
                 return(View(objTelephoneViewModel));
             }
         }
         //method for updating the record
         objTelephone.UpdateRecord(objTelephoneDto, phoneNumberOld);
         return(RedirectToAction("Index"));
     }
     return(View(objTelephoneViewModel));
 }
        public void UpdateRecord(TelephoneDirectoryRecordDTO objTelephoneRecordDto, string phoneNumberOld)
        {
            TelephoneDirectoryRecord objTelephoneRecordModel = DtoToModelMapping(objTelephoneRecordDto);

            objTelephone.UpdateRecord(objTelephoneRecordModel, phoneNumberOld);
        }
        public void CreateRecord(TelephoneDirectoryRecordDTO objTelephoneDto)
        {
            TelephoneDirectoryRecord objTelephoneRecordModel = DtoToModelMapping(objTelephoneDto);

            objTelephone.CreateRecord(objTelephoneRecordModel);
        }