public async Task <string> InsertOrUpdateSmartcard(SmartcardModel smartcard) { try { return(await Task.Run(() => service.InsertOrUpdateSmartcard(smartcard))); } catch (Exception) { throw; } }
public void MapSmartCardDBModel(SmartcardModel x, Smartcard y) { y.Cellphone = x.CellPhone; y.EmailAddress = x.EMail; y.Gender = x.Gender; y.LastUpdatedBy = "System"; y.LastUpdatedDate = DateTime.Now; y.Name = x.Name; y.SmartcardNumber = x.SmartcardNumber; y.Status = x.Status; y.Surname = x.Surname; y.CardType = x.CardType; y.AccountNumber = x.AccountNumber; y.Location = x.Location; }
public string InsertOrUpdateSmartcard(SmartcardModel smartcard) { var status = ""; try { unitOfWork.CreateTransaction(); if (smartcard.ID <= 0) { if (smartCardRepo.GetByCardNumber(smartcard.SmartcardNumber) == null) { Smartcard entity = MapSmartCardDBModel(smartcard); smartCardRepo.Insert(entity); unitOfWork.Save(); var guardians = MapGuardianDBModel(smartcard.Guardians, entity.ID); guardianRepo.BulkInsert(guardians); unitOfWork.Save(); } else { status = "Smartcard number is already regestired.!!"; } } else { var smartCardRec = smartCardRepo.GetById(smartcard.ID); MapSmartCardDBModel(smartcard, smartCardRec); smartCardRepo.Update(smartCardRec); guardianRepo.DeleteGuardiansForSmartCard(smartcard.ID); var guardians = MapGuardianDBModel(smartcard.Guardians, smartcard.ID); guardianRepo.BulkInsert(guardians); unitOfWork.Save(); } unitOfWork.Commit(); } catch (Exception) { unitOfWork.Rollback(); throw; } return(status); }
public Smartcard MapSmartCardDBModel(SmartcardModel x) { return(new Smartcard() { Cellphone = x.CellPhone, EmailAddress = x.EMail, Gender = x.Gender, ID = x.ID, LastUpdatedBy = "System", LastUpdatedDate = DateTime.Now, Name = x.Name, SmartcardNumber = x.SmartcardNumber, Status = x.Status, Surname = x.Surname, CardType = x.CardType, AccountNumber = x.AccountNumber, Location = x.Location }); }
public SmartcardModel GetSmartCard(int smartcardID) { SmartcardModel smartCardModel = null; try { var smartCard = smartCardRepo.GetById(smartcardID); if (smartCard != null) { var guardians = guardianRepo.GetGuardianForSmartCard(smartcardID); smartCardModel = MapSmartCardModel(smartCard); smartCardModel.Guardians = MapGuardianModel(guardians); } } catch (Exception) { throw; } return(smartCardModel); }