Example #1
0
        public List <Calling> getAll()
        {
            List <Calling> callings = new List <Calling>();

            foreach (List <string> data in database.retrieveData("select c.id, o.name, c.name from lds_calling c, lds_organization o " +
                                                                 "where c.organization_id = o.id " +
                                                                 "order by o.name, c.name"))
            {
                Calling calling = new Calling();
                calling.Name = string.Format("{0} - {1}", data[1], data[2]);
                calling.Id   = Convert.ToInt32(data[0]);
                callings.Add(calling);
            }
            return(callings);
        }
Example #2
0
        public List <Calling> getNextNMonths(int nInterval, int unitId)
        {
            List <Calling> list = new List <Calling>();

            foreach (List <string> data in database.retrieveData("select cm.id, cm.calling_id, cm.member_id, cm.other, " + common.formatDate("cm.calling_date") + ", cm.calling_flag " +
                                                                 "from lds_calling_member cm, lds_member m where cm.member_id = m.id and cm.calling_date >= date_sub(curdate(), interval 1 day) and cm.calling_date < DATE_ADD(curdate(), INTERVAL " + nInterval + " MONTH) " +
                                                                 " and m.unit_id = @unit_id order by cm.calling_date asc", unitId))
            {
                Calling call = new Calling();
                call.Id   = common.convertNumber(data[0]);
                call.Name = getCallingName(common.convertNumber(data[1]));
                Member member = new Member().getMember(common.convertNumber(data[2]), unitId);
                call.Member      = member.FirstName + " " + member.LastName;
                call.Other       = data[3];
                call.Date        = common.convertDate(data[4]);
                call.CallingFlag = common.convertBool(data[5]);
                list.Add(call);
            }
            return(list);
        }
Example #3
0
        public Calling get(int id, int unitId)
        {
            Calling call = null;

            foreach (List <string> data in database.retrieveData("select cm.id, cm.calling_id, cm.member_id, cm.other, " + common.formatDate("cm.calling_date") + ", cm.calling_flag " +
                                                                 "from lds_calling_member cm, lds_member m where cm.member_id = m.id and cm.id = @id and m.unit_id = @unit_id", id, unitId))
            {
                call           = new Calling();
                call.Id        = common.convertNumber(data[0]);
                call.Name      = getCallingName(common.convertNumber(data[1]));
                call.CallingId = common.convertNumber(data[1]);
                Member member = new Member().getMember(common.convertNumber(data[2]), unitId);
                call.MemberId    = common.convertNumber(data[2]);
                call.Member      = member.FirstName + " " + member.LastName;
                call.Other       = data[3];
                call.Date        = common.convertDate(data[4]);
                call.CallingFlag = common.convertBool(data[5]);
            }
            return(call);
        }
Example #4
0
        public ActionResult Edit(int id)
        {
            if (!isAuthenticated() || !loggedUser.isAdmin)
                return new HttpUnauthorizedResult();
            else
            {
                CallingViewModel model = new CallingViewModel();
                Calling call = new Calling().get(id, loggedUser.Unit);
                model.CallingId = call.CallingId;
                model.MemberId = call.MemberId;
                model.CallingFlag = new Common().convertBool(call.CallingFlag);
                model.Date = call.Date;
                model.Id = call.Id;
                model.Other = call.Other;

                ViewBag.unit = loggedUser.Unit;

                return View(model);
            }
        }
Example #5
0
        public ActionResult Edit(CallingViewModel model, int member, int calling, int callingFlag)
        {
            if (!isAuthenticated() || !loggedUser.isAdmin)
                return new HttpUnauthorizedResult();
            else
            {
                if (ModelState.IsValid)
                {
                    Calling call = new Calling();
                    Result result = call.update(model.Id, calling, member, string.Empty, model.Date, new Common().convertBool(callingFlag));
                    if (result.Success)
                        return RedirectToAction("Index");
                    else
                        ModelState.AddModelError("", "Ocorreu um erro ao atualizar chamado/desobrigação");
                }

                ViewBag.unit = loggedUser.Unit;

                return View(model);
            }
        }
Example #6
0
        public List <Calling> getAllCallings(int unit_id)
        {
            List <Calling> list = new List <Calling>();

            foreach (List <string> data in database.retrieveData("select cm.id, cm.calling_id, cm.member_id, cm.other, " + common.formatDate("cm.calling_date") + ", cm.calling_flag " +
                                                                 "	from lds_calling_member cm, lds_member m "+
                                                                 "	where cm.member_id = m.id "+
                                                                 "	  and m.unit_id = @unit_id "+
                                                                 "order by cm.calling_date asc", unit_id))
            {
                Calling call = new Calling();
                call.Id   = common.convertNumber(data[0]);
                call.Name = getCallingName(common.convertNumber(data[1]));
                Member member = new Member().getMember(common.convertNumber(data[2]), unit_id);
                call.Member      = member.FirstName + " " + member.LastName;
                call.Other       = data[3];
                call.Date        = common.convertDate(data[4]);
                call.CallingFlag = common.convertBool(data[5]);
                list.Add(call);
            }
            return(list);
        }
Example #7
0
 public Calling get(int id, int unitId)
 {
     Calling call = null;
     foreach (List<string> data in database.retrieveData("select cm.id, cm.calling_id, cm.member_id, cm.other, " + common.formatDate("cm.calling_date") + ", cm.calling_flag " +
         "from lds_calling_member cm, lds_member m where cm.member_id = m.id and cm.id = @id and m.unit_id = @unit_id", id, unitId))
     {
         call = new Calling();
         call.Id = common.convertNumber(data[0]);
         call.Name = getCallingName(common.convertNumber(data[1]));
         call.CallingId = common.convertNumber(data[1]);
         Member member = new Member().getMember(common.convertNumber(data[2]), unitId);
         call.MemberId = common.convertNumber(data[2]);
         call.Member = member.FirstName + " " + member.LastName;
         call.Other = data[3];
         call.Date = common.convertDate(data[4]);
         call.CallingFlag = common.convertBool(data[5]);
     }
     return call;
 }
Example #8
0
 public List<Calling> getNextNMonths(int nInterval, int unitId)
 {
     List<Calling> list = new List<Calling>();
     foreach (List<string> data in database.retrieveData("select cm.id, cm.calling_id, cm.member_id, cm.other, " + common.formatDate("cm.calling_date") + ", cm.calling_flag " +
         "from lds_calling_member cm, lds_member m where cm.member_id = m.id and cm.calling_date >= date_sub(curdate(), interval 1 day) and cm.calling_date < DATE_ADD(curdate(), INTERVAL " + nInterval + " MONTH) " +
         " and m.unit_id = @unit_id order by cm.calling_date asc", unitId))
     {
         Calling call = new Calling();
         call.Id = common.convertNumber(data[0]);
         call.Name = getCallingName(common.convertNumber(data[1]));
         Member member = new Member().getMember(common.convertNumber(data[2]), unitId);
         call.Member = member.FirstName + " " + member.LastName;
         call.Other = data[3];
         call.Date = common.convertDate(data[4]);
         call.CallingFlag = common.convertBool(data[5]);
         list.Add(call);
     }
     return list;
 }
Example #9
0
 public List<Calling> getAllCallings(int unit_id)
 {
     List<Calling> list = new List<Calling>();
     foreach (List<string> data in database.retrieveData("select cm.id, cm.calling_id, cm.member_id, cm.other, " + common.formatDate("cm.calling_date") + ", cm.calling_flag " +
         "	from lds_calling_member cm, lds_member m " +
         "	where cm.member_id = m.id " +
         "	  and m.unit_id = @unit_id " +
         "order by cm.calling_date asc", unit_id))
     {
         Calling call = new Calling();
         call.Id = common.convertNumber(data[0]);
         call.Name = getCallingName(common.convertNumber(data[1]));
         Member member = new Member().getMember(common.convertNumber(data[2]), unit_id);
         call.Member = member.FirstName + " " + member.LastName;
         call.Other = data[3];
         call.Date = common.convertDate(data[4]);
         call.CallingFlag = common.convertBool(data[5]);
         list.Add(call);
     }
     return list;
 }
Example #10
0
 public List<Calling> getAll()
 {
     List<Calling> callings = new List<Calling>();
     foreach (List<string> data in database.retrieveData("select c.id, o.name, c.name from lds_calling c, lds_organization o " +
         "where c.organization_id = o.id " +
         "order by o.name, c.name"))
     {
         Calling calling = new Calling();
         calling.Name = string.Format("{0} - {1}", data[1], data[2]);
         calling.Id = Convert.ToInt32(data[0]);
         callings.Add(calling);
     }
     return callings;
 }