Example #1
0
 public bool Delete(int AISTrackId)
 {
     try
     {
         using (AISTrackRepository aisTrackRepo = new AISTrackRepository())
         {
             var AISTrackExisting = aisTrackRepo.Get <AISTrack>(AISTrackId);
             if (AISTrackExisting == null)
             {
                 return(false);
             }
             else
             {
                 aisTrackRepo.Delete <AISTrack>(AISTrackId);
                 if (MemCache.IsIncache("AllAISTracksKey"))
                 {
                     MemCache.GetFromCache <List <AISTrack> >("AllAISTracksKey").Remove(AISTrackExisting);
                 }
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #2
0
        public bool Update(AISTrack AISTrackModel)
        {
            try
            {
                using (AISTrackRepository aisTrackRepo = new AISTrackRepository())
                {
                    if (MemCache.IsIncache("AllAISTracksKey"))
                    {
                        List <AISTrack> aISTracks = MemCache.GetFromCache <List <AISTrack> >("AllStakeholdersKey");
                        if (aISTracks.Count > 0)
                        {
                            aISTracks.Remove(aISTracks.Find(x => x.AISTrackId == AISTrackModel.AISTrackId));
                        }
                    }

                    aisTrackRepo.Update <AISTrack>(AISTrackModel);
                    if (MemCache.IsIncache("AllStakeholdersKey"))
                    {
                        MemCache.GetFromCache <List <AISTrack> >("AllStakeholdersKey").Add(AISTrackModel);
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #3
0
 public AISTrack Add(AISTrack AISTrackModel)
 {
     try
     {
         using (AISTrackRepository aisTrackRepo = new AISTrackRepository())
         {
             // Validate and Map data over here
             if (AISTrackModel != null)
             {
                 var rowId = aisTrackRepo.Insert <AISTrack>(AISTrackModel);
                 AISTrackModel.AISTrackId = rowId;
             }
             if (MemCache.IsIncache("AllAISTracksKey"))
             {
                 MemCache.GetFromCache <List <AISTrack> >("AllAISTracksKey").Add(AISTrackModel);
             }
             else
             {
                 List <AISTrack> tracks = new List <AISTrack>();
                 tracks.Add(AISTrackModel);
                 MemCache.AddToCache("AllAISTracksKey", tracks);
             }
             return(AISTrackModel);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #4
0
        public List <AISTrack> List(Dictionary <string, string> dic = null)
        {
            try
            {
                List <AISTrack> lstAISTracks = new List <AISTrack>();
                if (MemCache.IsIncache("AllAISTracksKey"))
                {
                    return(MemCache.GetFromCache <List <AISTrack> >("AllAISTracksKey"));
                }
                else
                {
                    if (dic == null)
                    {
                        dic = new Dictionary <string, string>();
                    }

                    dic.Add("orderby", "MMSI");
                    dic.Add("offset", "1");
                    dic.Add("limit", "200");

                    var parameters = this.ParseParameters(dic);
                    using (AISTrackRepository aisTrackRepo = new AISTrackRepository())
                    {
                        lstAISTracks = aisTrackRepo.GetListPaged <AISTrack>(Convert.ToInt32(dic["offset"]), Convert.ToInt32(dic["limit"]), parameters, dic["orderby"]).ToList();
                        return(lstAISTracks);
                    }
                }
            }
            catch (Exception ex)
            {
                //_trace.Error("Error Retrieving Data", exception: ex);
                throw ex;
            }
        }
Example #5
0
        public AmplifyingReportView Add(Subscriber SubsModel, string UserName, AmplifyingReport ARModel)
        {
            try
            {
                if (SubsModel == null)
                {
                    throw new Exception("Subscriber model is null");
                }
                else if (ARModel == null)
                {
                    throw new Exception("Preliminary report model is null");
                }

                using (AmplifyingReportRepository ARRepo = new AmplifyingReportRepository())
                {
                    AmplifyingReportView ARView        = new AmplifyingReportView();
                    string coiNumber                   = "";
                    List <AmplifyingReportView> lstARs = ARRepo.GetList <AmplifyingReportView>(new { COI_ID = ARModel.COIId }).ToList();

                    using (COIRepository coiRepo = new COIRepository())
                    {
                        coiNumber = coiRepo.Get <COI>(ARModel.COIId).COINumber;
                    }
                    string generatedARNo = coiNumber + "-AR-" + 1;

                    ARView = lstARs.OrderByDescending(x => x.ARId).FirstOrDefault();
                    if (ARView != null)
                    {
                        generatedARNo = Common.GetNextSubReportNumber(ARView.ARNumber);
                    }

                    ARModel.ARNumber             = generatedARNo;
                    ARModel.ActionAddressee      = string.Join(",", ARModel.ActionAddresseeArray);
                    ARModel.InformationAddressee = string.Join(",", ARModel.InformationAddresseeArray);
                    ARModel.ReportingDatetime    = Common.GetLocalDateTime(MemCache.GetFromCache <string>("Timezone_" + SubsModel.SubscriberId));
                    ARModel.SubscriberId         = SubsModel.SubscriberId;
                    ARModel.CreatedOn            = Common.GetLocalDateTime(MemCache.GetFromCache <string>("Timezone_" + SubsModel.SubscriberId));
                    ARModel.CreatedBy            = UserName;

                    int rowId = ARRepo.Insert(ARModel);
                    return(ARView = GetById(rowId));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #6
0
 public bool Update(int SubscriberId, string UserName, AfterActionReport AARModel)
 {
     try
     {
         using (AfterActionReportRepository AARRepo = new AfterActionReportRepository())
         {
             AARModel.LastModifiedOn = Common.GetLocalDateTime(MemCache.GetFromCache <string>("Timezone_" + SubscriberId));
             AARModel.LastModifiedBy = UserName;
             AARRepo.Update <AfterActionReport>(AARModel);
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #7
0
 public AAASIncident Add(AAASIncident AIModel, int SubscriberId, string UserName)
 {
     try
     {
         using (AAASIncidentRepository AIRepo = new AAASIncidentRepository())
         {
             if (AIModel != null)
             {
                 AIModel.CreatedOn = Common.GetLocalDateTime(MemCache.GetFromCache <string>("Timezone_" + SubscriberId));
                 AIModel.CreatedBy = UserName;
                 var rowId = AIRepo.Insert(AIModel);
                 AIModel.Id = rowId;
             }
             return(AIModel);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #8
0
        public AfterActionReportView Add(Subscriber SubsModel, string UserName, AfterActionReport AARModel)
        {
            try
            {
                using (AfterActionReportRepository aarRepo = new AfterActionReportRepository())
                {
                    AfterActionReportView aarView = new AfterActionReportView();
                    AARModel.AddressedTo       = string.Join(",", AARModel.AddressedToArray);
                    AARModel.ReportingDatetime = Common.GetLocalDateTime(MemCache.GetFromCache <string>("Timezone_" + SubsModel.SubscriberId));
                    AARModel.SubscriberId      = SubsModel.SubscriberId;
                    AARModel.CreatedOn         = Common.GetLocalDateTime(MemCache.GetFromCache <string>("Timezone_" + SubsModel.SubscriberId));
                    AARModel.CreatedBy         = UserName;

                    int rowId = aarRepo.Insert(AARModel);
                    return(aarView = GetById(rowId));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #9
0
 public AISTrack GetById(int AISTrackId)
 {
     try
     {
         if (MemCache.IsIncache("AllAISTracksKey"))
         {
             return(MemCache.GetFromCache <List <AISTrack> >("AllAISTracksKey").Where <AISTrack>(x => x.AISTrackId == AISTrackId).FirstOrDefault());
         }
         using (AISTrackRepository aisTrackRepo = new AISTrackRepository())
         {
             AISTrack AISTrackModel = new AISTrack();
             {
                 AISTrackModel = aisTrackRepo.Get <AISTrack>(AISTrackId);
                 return(AISTrackModel);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }