public void Update(BTSTechnologyDTO btsTechnologyDTO, DateTime dateStamp) { if (btsTechnologyDTO == null) { throw new ArgumentNullException("BTSTechnology model is null."); } tblM_BTSTechnology btsTechnology = btsTechnologyFactory.CreateFromDbAndUpdateFromDTO(btsTechnologyDTO, dateStamp); }
public tblM_BTSTechnology Insert(BTSTechnologyDTO btsTechnologyDTO, DateTime dateStamp) { if (btsTechnologyDTO == null) { throw new ArgumentNullException("BTSTechnology model is null."); } tblM_BTSTechnology btsTechnology = btsTechnologyFactory.CreateFromDTO(btsTechnologyDTO, dateStamp); return(Db.tblM_BTSTechnology.Add(btsTechnology)); }
public tblM_BTSTechnology AddBTSTechno(BTSTechnologyDTO btstDTO, DateTime dateStamp) { if (btstDTO == null) { throw new ArgumentNullException("BTS model is null."); } tblM_BTSTechnology btst = btstFactory.CreateFromDTO(btstDTO, dateStamp); btst = Db.tblM_BTSTechnology.Add(btst); return(btst); }
private BTSTechnologyEntryModel GetCreateStateModel() { BTSTechnologyEntryFormData formData = new BTSTechnologyEntryFormData(); List <Control> formControls = CreateFormControls(0); BTSTechnologyDTO btsTechnologyDTO = new BTSTechnologyDTO(); return(new BTSTechnologyEntryModel() { FormData = formData, FormControls = formControls, Model = btsTechnologyDTO, }); }
private BTSTechnologyEntryModel GetUpdateStateModel(int btsTechnologyPK) { BTSTechnologyEntryFormData formData = new BTSTechnologyEntryFormData(); List <Control> formControls = CreateFormControls(btsTechnologyPK); BTSTechnologyDTO btsTechnologyDTO = btsTechnologyQuery.GetByPrimaryKey(btsTechnologyPK); if (btsTechnologyDTO == null) { throw new KairosException($"Record with primary key '{btsTechnologyDTO.BTSTechnology_PK}' is not found."); } return(new BTSTechnologyEntryModel() { FormData = formData, FormControls = formControls, Model = btsTechnologyDTO, }); }
public SaveResult <BTSTechnologyEntryModel> Save(BTSTechnologyDTO btsTechnologyDTO, DateTime dateStamp) { ModelValidationResult validationResult = btsTechnologyValidator.Validate(btsTechnologyDTO); bool success = false; BTSTechnologyEntryModel model = null; if (validationResult.IsValid) { success = true; Update(btsTechnologyDTO, dateStamp); Db.SaveChanges(); model = btsTechnologyEntryDataProvider.Get(btsTechnologyDTO.BTSTechnology_PK); } return(new SaveResult <BTSTechnologyEntryModel> { Success = success, Message = validationResult.IsValid ? "Data successfully updated." : "Validation error occured.", Model = model, ValidationResult = validationResult }); }
public List <BTSDTO> CreateListFromExcelBase64(BTSImportDTO importDTO) { var base64 = importDTO.File; base64 = base64.Replace("data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,", ""); var wb = ExcelConverter.FromBase64(base64); var sheet = wb.Worksheet("BTSUpload"); var nonEmptyRowCount = sheet.RowsUsed().Count() + 1; var areaQuery = new AreaQuery(Db); var operatorQuery = new OperatorQuery(Db); var technologyQuery = new TechnologyQuery(Db); var btsQuery = new BTSQuery(Db); List <BTSDTO> btsList = new List <BTSDTO>(); //first index is 1, and the first one is header title for (int i = 2; i < nonEmptyRowCount; i++) { var row = sheet.Row(i); var towerId = row.Cell(1).Value.ToString(); var btsName = row.Cell(2).Value.ToString(); //get by itsname first; var btsDtoOnDb = btsQuery.GetByTowerID(towerId); var btsPk = 0; if (btsDtoOnDb == null) { btsDtoOnDb = btsQuery.GetByName(btsName); } if (btsDtoOnDb != null) { btsPk = btsDtoOnDb.BTS_PK; } var cellId = row.Cell(3).Value.ToString(); var operatorName = row.Cell(4).Value.ToString(); var operatorId = operatorQuery.GetByTitle(operatorName).Operator_PK; var longitude = Convert.ToString(row.Cell(5).Value); var latitude = Convert.ToString(row.Cell(6).Value); var areaName = row.Cell(7).Value.ToString(); var areaId = areaQuery.GetByTitle(areaName).Area_PK; var address = row.Cell(8).Value.ToString(); var status = row.Cell(9).Value.ToString(); List <BTSTechnologyDTO> techno = new List <BTSTechnologyDTO>(); var technology = row.Cell(10).Value.ToString().Split(';').ToList(); foreach (var item in technology) { BTSTechnologyDTO itemtech = new BTSTechnologyDTO(); try { itemtech.Technology_FK = technologyQuery.GetByTitle(item).Technology_PK; } catch (Exception) { itemtech.Technology_FK = 0; } techno.Add(itemtech); } btsList.Add(new BTSDTO() { BTS_PK = btsPk, Name = btsName, CellID = cellId, Latitude = latitude, Longitude = longitude, Alamat = address, Area_FK = areaId, AreaTitle = areaName, OperatorTitle = operatorName, Operator_FK = operatorId, Status_FK = 1, TowerID = towerId, StatusBTS_FK = 1, BTSTechnologies = techno }); } return(btsList); }
public BTSTechnologyDTO GetByPrimaryKey(int primaryKey) { BTSTechnologyDTO record = GetQuery().FirstOrDefault(btsTechnology => btsTechnology.BTSTechnology_PK == primaryKey); return(record); }