Example #1
0
        public TOfficer bringTOfficer(string id)
        {
            TOfficerRepository repo = new TOfficerRepository();
            TOfficer           data = repo.Get(Convert.ToInt32(id));

            return(data);
        }
        public IHttpActionResult Post(TOfficer tOfficer)
        {
            this.trepo.Insert(tOfficer);
            string uri = Url.Link("GetUserById", new { id = tOfficer.TO_accId });

            return(Created("GetCategoryById", tOfficer));
        }
        public int Delete(int id)
        {
            TOfficer TOfficerToDelete = context.TOfficers.SingleOrDefault(d => d.TO_accId == id);

            context.TOfficers.Remove(TOfficerToDelete);
            return(context.SaveChanges());
        }
        public int Insert(TOfficer TOfficer)
        {
            Logininfo li = new Logininfo();

            li.Login_acc_no   = context.TOfficers.Count() + 1;
            li.Login_Name     = TOfficer.TO_name;
            li.Login_Password = TOfficer.TO_password;
            li.Login_type     = "TOfficer";
            context.Logininfos.Add(li);
            context.TOfficers.Add(TOfficer);
            return(context.SaveChanges());
        }
        public int Update(TOfficer TOfficer)
        {
            TOfficer TOfficerToUpdate = context.TOfficers.SingleOrDefault(d => d.TO_accId == TOfficer.TO_accId);

            TOfficerToUpdate.TO_name     = TOfficer.TO_name;
            TOfficerToUpdate.TO_password = TOfficer.TO_password;
            TOfficerToUpdate.TO_address  = TOfficer.TO_address;
            TOfficerToUpdate.TO_mobile   = TOfficer.TO_mobile;
            TOfficerToUpdate.TO_branch   = TOfficer.TO_branch;


            return(context.SaveChanges());
        }
        public IHttpActionResult Get(int TO_accId)
        {
            TOfficer u = new TOfficer();

            u = this.trepo.Get(TO_accId);

            if (u == null)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                return(Ok(u));
            }
        }
 public IHttpActionResult Put([FromBody] TOfficer tOfficer, [FromUri] int TO_accId)
 {
     tOfficer.TO_accId = TO_accId;
     this.trepo.Update(tOfficer);
     return(Ok(tOfficer));
 }
 // GET: TOfficer
 public ActionResult Home(TOfficer ho)
 {
     Session["TOfficer"] = ho;
     return(RedirectToAction("Home1"));
 }