Exemple #1
0
        public bool PostGuardDuty(GuardDuty g)
        {
            try
            {
                Guard_Duty gd = new Guard_Duty();


                gd.Visitor_Name = g.Visitor_Name;
                gd.In_Datetime  = g.In_Datetime;
                gd.Out_Datetime = g.Out_Datetime;
                gd.Details      = g.Details;
                gd.House_ID     = g.House_ID;
                gd.Require      = g.Require;

                es.Guard_Duty.Add(gd);
                var res = es.SaveChanges();

                if (res > 0)
                {
                    return(true);
                }
                return(false);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public IEnumerable <GuardDuty> GetGuardDuty()
        {
            try
            {
                var res = es.Guard_Duty.ToList();

                List <GuardDuty> gd = new List <GuardDuty>();

                foreach (var r in res)
                {
                    GuardDuty g = new GuardDuty();

                    g.Visitor_ID   = r.Visitor_ID;
                    g.Visitor_Name = r.Visitor_Name;
                    g.In_Datetime  = r.In_Datetime;
                    g.Out_Datetime = r.Out_Datetime;
                    g.Details      = r.Details;
                    g.House_ID     = r.House_ID;
                    g.Require      = (int)r.Require;

                    gd.Add(g);
                }
                return(gd);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
0
        public GuardDuty GetByIdVistor(int id)
        {
            try
            {
                GuardDuty g = new GuardDuty();

                var r = es.Guard_Duty.Where(i => i.Visitor_ID == id).SingleOrDefault();

                if (r != null)
                {
                    g.Visitor_ID   = r.Visitor_ID;
                    g.Visitor_Name = r.Visitor_Name;
                    g.In_Datetime  = r.In_Datetime;
                    g.Out_Datetime = r.Out_Datetime;
                    g.Details      = r.Details;
                    g.House_ID     = r.House_ID;
                    g.Require      = (int)r.Require;
                }
                else
                {
                    throw new Exception("Invalid Visitor ID");
                }

                return(g);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #4
0
        public string PutGuardDuty(int id, GuardDuty g)
        {
            try
            {
                var gd = (from t in es.Guard_Duty
                          where t.Visitor_ID == id
                          select t).SingleOrDefault();
                if (g == null)
                {
                    return("Invalid Visitor ID");
                }
                else
                {
                    gd.Visitor_Name = g.Visitor_Name;
                    gd.In_Datetime  = g.In_Datetime;
                    gd.Out_Datetime = g.Out_Datetime;
                    gd.Details      = g.Details;
                    gd.House_ID     = g.House_ID;
                    gd.Require      = g.Require;

                    var res = es.SaveChanges();
                    if (res > 0)
                    {
                        return("Data Updated Succesfully");
                    }
                    return("Error in updation");
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
 public string Put(int id, [FromBody] GuardDuty g)
 {
     return(gd.PutGuardDuty(id, g));
 }
 public bool Post([FromBody] GuardDuty g)
 {
     return(gd.PostGuardDuty(g));
 }
Exemple #7
0
 string IGuardDuty.PutGuardDuty(GuardDuty g, int id)
 {
     throw new NotImplementedException();
 }