public void CreateAnt(QueenDomainModel objDM) { #region using SQLite & Entity Framework #endregion #region using text file try { List <string> output = File.ReadAllLines(filePath).ToList(); output.Add($"{objDM.Id}, {objDM.AntName}, {objDM.AntType}, {objDM.AntAge}"); File.WriteAllLines(filePath, output); } catch (Exception) { throw; } #endregion }
public void CreateAnt(QueenViewModel objVM) { // Validating age var ageValidator = new AgeValidator(); bool isAgeCorrect = ageValidator.Validate(objVM.AntAge, objVM.AntType); if (isAgeCorrect == true) { // Mapping ViewModel -> DomainModel var objDM = new QueenDomainModel(); objDM.Id = objVM.Id; objDM.AntName = objVM.AntName; objDM.AntType = objVM.AntType; objDM.AntAge = objVM.AntAge; this._antRepo.CreateAnt(objDM); } }