zoukankan      html  css  js  c++  java
  • MemberController

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Web;

    using System.Web.Mvc;

     

    using Teamwork.ProjectServiceReference;

     

     

    namespace Teamwork.Controllers

    {

        public class MemberController : Controller

        {

            Teamwork.ProjectServiceReference.ProjectServiceClient sv = new ProjectServiceClient();

           

            //@model IEnumerable<Teamwork.ProjectServiceReference.Member>

            public ActionResult Index()

            {

                MemberCollection mbCollection = new MemberCollection();

     

                mbCollection = sv.GetMembers();

                List<Member> ls = new List<Member>();

     

                if (mbCollection!=null && mbCollection.Count > 0)

                {

                   

                    //ls = mbCollection.ToList<Member>();

                    foreach (MyMember mymb in mbCollection )

                    {

                        ls.Add(sv.ConvertMemberToEfEntity(mymb));

                    }

                    return View(ls);

                }

     

                return View();

            }

     

            //@model Teamwork.ProjectServiceReference.Member

            public ActionResult Detail(int id)

            {

                Member mb = sv.GetMemberById(id);

                return View(mb);

            }

     

            //@model Teamwork.ProjectServiceReference.MyMember

            public ActionResult Create()

            {

                return View();

            }

     

            [HttpPost]

            //@model Teamwork.ProjectServiceReference.MyMember

            public ActionResult Create(MyMember mymb )

            {

                int iReturn = -1;

                try

                {

                    // TODO: Add insert logic here

                    if (mymb != null)

                    {

                        iReturn=sv.CreateMember(mymb);

                    }

     

                    if (iReturn == 1)

                    {

                        return View("Created");

                    }

                    else

                    {

                        return RedirectToAction("Index");

                    }

                

                }

                catch

                {

                    return View();

                }

           }//Create

     

            //@model Teamwork.ProjectServiceReference.MyMember

            public ActionResult Edit(int id)

            {

                Member member = sv.GetMemberById(id);

                MyMember mymb = sv.ConvertMemberToWcfEntity(member);

            

                ViewBag.Projects = sv.GetMemberProjects(member.LoginName);

                return View(mymb);

            

            }

          

            [HttpPost]

            //@model Teamwork.ProjectServiceReference.MyMember

            public ActionResult Edit(int id, FormCollection collection)

            {

                try

                {

                    // TODO: Add update logic here

                    Member mb = sv.GetMemberById(id);

                    mb.LoginName = collection["LoginName"];        

                    mb.Name = collection["Name"];      

                    MyMember mymb = sv.ConvertMemberToWcfEntity(mb);

              

                    int iReturn = sv.UpdateMember(mymb);

                    if (iReturn == 1)

                    {

                        ViewBag.Projects = sv.GetMemberProjects(mb.LoginName);//added by dd,2011-07-27

                        return View("Edited");

                    }

                    else

                    {

                        return RedirectToAction("Index");

                    }            

                }

                catch

                {

                    return View("Index");

                }

            }//Edit

     

            //@model Teamwork.ProjectServiceReference.Member

            public ActionResult Delete(int id)

            {

               Member mb = sv.GetMemberById(id);

                return View(mb);

            }

     

            [HttpPost]

           // @model Teamwork.ProjectServiceReference.Member

            public ActionResult Delete(int id, FormCollection collection)

            {

                int iReturn=-1;

                try

                {

                    // TODO: Add delete logic here

                    if (id > 0)

                    {

                        iReturn = sv.DeleteMemberById(id);

                    }

                    if (iReturn == 1)

                    {

                        return View("Deleted");

                    }

                    else

                    {

                        return RedirectToAction("Index");

                    }

                }

                catch

                {

                    return View();

                }

            }//Delete

     

        }

    }

     

  • 相关阅读:
    influxdb服务器 relay
    browse-agent type and curl post
    使用 Ansible 管理 MySQL 复制
    ansible里的item和with_items
    Ansible 从MySQL数据库添加或删除用户
    ansibel---tag模块
    ll | wc -l的陷阱
    ansible 判断和循环
    Ansible详解(二)
    Ansible详解(一)
  • 原文地址:https://www.cnblogs.com/quietwalk/p/2117958.html
Copyright © 2011-2022 走看看