// add support type delivered to the group public void addSupportType(int vslaId, int trainerId, string supportType) { DateTime supportDate = DateTime.Now; GroupSupportType gst; GroupSupportRepo supportRepo = null; string success = string.Empty; DigitizingDataDomain.Model.GroupSupport groupSupport = null; try { gst = new GroupSupportType(); supportRepo = new GroupSupportRepo(); groupSupport = new DigitizingDataDomain.Model.GroupSupport(); // vsla DigitizingDataDomain.Model.Vsla vsla = new DigitizingDataDomain.Model.Vsla(); vsla.VslaId = Convert.ToInt32(vslaId); groupSupport.VslaId = vsla; // cbt DigitizingDataDomain.Model.TechnicalTrainer cbt = new DigitizingDataDomain.Model.TechnicalTrainer(); cbt.Id = Convert.ToInt32(trainerId); groupSupport.TrainerId = cbt; // support date groupSupport.SupportDate = supportDate; // support type groupSupport.SupportType = supportType; // add support type attached to a group supportRepo.Insert(groupSupport); } catch (Exception) { throw; } }
// add a new vsla public OperationResult addNewVsla(Stream jsonStream) { StreamReader reader = new StreamReader(jsonStream); string data = reader.ReadToEnd(); VslaDetails request; String _vslaCode = string.Empty; OperationResult operationResult = null; try { operationResult = new OperationResult(); _vslaCode = genVslaCode(); request = JsonConvert.DeserializeObject <VslaDetails>(data); DigitizingDataDomain.Model.Vsla vsla = new DigitizingDataDomain.Model.Vsla(); vsla.VslaName = Convert.ToString(request.VslaName); vsla.VslaCode = Convert.ToString(_vslaCode); vsla.PhoneNumber = Convert.ToString(request.repPhoneNumber); vsla.ContactPerson = Convert.ToString(request.representativeName); vsla.VslaPhoneMsisdn = Convert.ToString(request.grpPhoneNumber); vsla.PositionInVsla = Convert.ToString(request.representativePosition); vsla.DateRegistered = DateTime.Now; vsla.DateLinked = DateTime.Now; vsla.PhysicalAddress = Convert.ToString(request.PhysicalAddress); vsla.GpsLocation = Convert.ToString(request.GpsLocation); vsla.GroupAccountNumber = Convert.ToString(request.GroupAccountNumber); vsla.Status = 1; vsla.NumberOfCycles = Convert.ToInt32(request.numberOfCycles); vsla.Implementer = Convert.ToString(request.Implementer); // cbt DigitizingDataDomain.Model.TechnicalTrainer cbt = new DigitizingDataDomain.Model.TechnicalTrainer(); cbt.Id = Convert.ToInt32(request.tTrainerId); vsla.CBT = cbt; // region id DigitizingDataDomain.Model.VslaRegion vslaRegion = new DigitizingDataDomain.Model.VslaRegion(); vslaRegion.RegionId = Convert.ToInt32(request.RegionName); vsla.VslaRegion = vslaRegion; VslaRepo vslaRepo = new VslaRepo(); Boolean result = vslaRepo.Insert(vsla); if (result) { // SUCCESS operationResult.operation = "create"; operationResult.result = "1"; operationResult.VslaCode = _vslaCode; } else { // FAILED operationResult.operation = null; operationResult.result = "-1"; operationResult.VslaCode = null; } } catch (Exception e) { } return(operationResult); }