Exemplo n.º 1
0
        public static List <PocketCheckViewModel> GetDependentPocketChecks(int id)
        {
            using (OpidDailyDB opiddailycontext = new OpidDailyDB())
            {
                PocketCheck pcheck = opiddailycontext.PocketChecks.Find(id);

                if (pcheck != null)
                {
                    Client client = opiddailycontext.Clients.Find(pcheck.ClientId);

                    if (client != null)
                    {
                        List <PocketCheck>          dependentPocketChecks = opiddailycontext.PocketChecks.Where(pc => pc.HH == client.Id).ToList();
                        List <PocketCheckViewModel> pcvms = new List <PocketCheckViewModel>();

                        foreach (PocketCheck dependentPocketCheck in dependentPocketChecks)
                        {
                            PocketCheckViewModel pcvm = PocketCheckToPocketCheckViewModel(client, dependentPocketCheck);
                            pcvms.Add(pcvm);
                        }

                        return(pcvms);
                    }

                    return(null);
                }

                return(null);
            }
        }
Exemplo n.º 2
0
        public static void DeletePocketCheck(int nowServing, int id)
        {
            try
            {
                using (OpidDailyDB opiddailycontext = new OpidDailyDB())
                {
                    Client client = opiddailycontext.Clients.Find(nowServing);

                    if (client != null)
                    {
                        PocketCheck pcheck = opiddailycontext.PocketChecks.Where(p => p.ClientId == nowServing).SingleOrDefault();

                        if (pcheck != null)
                        {
                            DeleteVisitNotes(pcheck.Id);
                            opiddailycontext.PocketChecks.Remove(pcheck);
                            opiddailycontext.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(string.Format("Could not delete client with id = {0} Error {1}", nowServing, e.Message));
            }
        }
Exemplo n.º 3
0
 private static bool IsPocketCheck(PocketCheck pcheck)
 {
     // Does not depend on Disposition, which might not be determined yet.
     // It's still a pocket check based on check number alone.
     // See CheckManager.PocketCheck which DOES depend on disposition.
     return(0 < pcheck.Num && pcheck.Num < 9999);
 }
Exemplo n.º 4
0
        public static void EditPocketCheck(PocketCheckViewModel pcvm)
        {
            using (OpidDailyDB opiddailycontext = new DataContexts.OpidDailyDB())
            {
                PocketCheck pcheck = opiddailycontext.PocketChecks.Where(pc => pc.Id == pcvm.Id).SingleOrDefault();

                if (pcheck != null)
                {
                    pcheck.Notes = pcvm.Notes;
                    opiddailycontext.SaveChanges();
                }
            }
        }
Exemplo n.º 5
0
 private static VisitViewModel PocketCheckToVisitViewModel(PocketCheck pcheck)
 {
     return(new VisitViewModel
     {
         Id = pcheck.Id,
         Date = pcheck.Date,
         //  Conversation = (HavingConversation(pcheck.Id) ? "Y" : string.Empty),
         Item = pcheck.Item,
         Check = pcheck.Num.ToString(),
         Status = pcheck.Disposition,
         Sender = MostRecentSender(pcheck.Id),
         Notes = pcheck.Notes
     });
 }
Exemplo n.º 6
0
        public static void EditVisit(int nowServing, VisitViewModel vvm)
        {
            using (OpidDailyDB opiddailycontext = new OpidDailyDB())
            {
                Client client = opiddailycontext.Clients.Find(nowServing);

                if (client != null)
                {
                    AncientCheck ancientCheck = opiddailycontext.AncientChecks.Find(vvm.Id);

                    if (ancientCheck != null)
                    {
                        ancientCheck.Date        = vvm.Date;
                        ancientCheck.Num         = Convert.ToInt32(vvm.Check);
                        ancientCheck.Service     = vvm.Item;
                        ancientCheck.Disposition = vvm.Status;
                        ancientCheck.Notes       = vvm.Notes;
                        opiddailycontext.SaveChanges();
                        return;
                    }

                    RCheck rcheck = opiddailycontext.RChecks.Find(vvm.Id);

                    if (rcheck != null)
                    {
                        rcheck.Date        = vvm.Date;
                        rcheck.Num         = Convert.ToInt32(vvm.Check);
                        rcheck.Service     = vvm.Item;
                        rcheck.Disposition = vvm.Status;
                        rcheck.Notes       = vvm.Notes;
                        opiddailycontext.SaveChanges();
                        return;
                    }

                    PocketCheck pcheck = opiddailycontext.PocketChecks.Find(vvm.Id);

                    if (pcheck != null)
                    {
                        pcheck.Date        = vvm.Date;
                        pcheck.Item        = vvm.Item;
                        pcheck.Num         = Convert.ToInt32(vvm.Check);
                        pcheck.Disposition = vvm.Status;
                        pcheck.Notes       = vvm.Notes;
                        opiddailycontext.SaveChanges();
                        return;
                    }
                }
            }
        }
Exemplo n.º 7
0
 private static PocketCheckViewModel PocketCheckToPocketCheckViewModel(Client client, PocketCheck pc)
 {
     return(new PocketCheckViewModel
     {
         Id = pc.Id,
         AgencyName = (!string.IsNullOrEmpty(client.AgencyName) ? client.AgencyName : Agencies.GetAgencyName(client.AgencyId)),
         Name = pc.Name,
         HeadOfHousehold = (pc.HeadOfHousehold ? "Y" : string.Empty),
         Date = pc.Date,
         Item = pc.Item,
         Check = pc.Num,
         Status = pc.Disposition,
         Notes = pc.Notes
     });
 }