[ create a new paste ] login | about

Link: http://codepad.org/Go7uUrz6    [ raw code | output | fork ]

C, pasted on Jun 11:
//CONTROLLER
using OnlineShop.DAO;
using OnlineShop.EF;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PagedList;

namespace OnlineShop.Areas.Admin.Controllers
{
    public class UserController : BaseController
    {
        // GET: Admin/User
        public ActionResult Index(int Page=1,int Pagesize=1)//Mot Ban ghi 1 trang
        {
            var model = new UserDao();
            return View(model.ShowAllUser());
        }
        [HttpGet]
        public ActionResult Create()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Create(User x)
        {
            if(ModelState.IsValid)
            {
                var dao = new UserDao();
                var MD5 = Commond.Encrytor.MD5Hash(x.Password);
                x.Password = MD5;
                long id =dao.InsertUser(x);
                if(id>0)
                {
                    return RedirectToAction("Index", "User");
                }
                else
                {
                    ModelState.AddModelError("", "TheM That bai!");
                }

            }
            return View("Index");
        }
        public ActionResult Edit(int id=1)
        {
            var Model = new UserDao();
            Model.GetUserFollowId(id);
            return View(Model);
        }
    }
}
//Modelusing OnlineShop.EF;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PagedList;

namespace OnlineShop.DAO
{
    public class UserDao
    {
        OnlineDB DB = null;
        public UserDao()
        {
            DB = new OnlineDB();
        }
        //Method ShowAll List User
         public IEnumerable<User> ShowAllUser()
        {
            var item = from i in DB.Users
                       select i;
            return item;
        }
        public User GetUserFollowId(int id)
        {
            return DB.Users.Find(id);
        }
        //Update
        public bool UpdateOneUser(User Etity)
        {
            try
            {
                var User = DB.Users.Find(Etity.ID);
                User.Password = Etity.Password;
                User.Status = Etity.Status;
                User.UserName = Etity.UserName;
                DB.SaveChanges();

            }
            catch(Exception e)
            {
                return false;
            }
            return true;
        }
        //Method Inser user
        public long InsertUser(User Entity)
        {
            DB.Users.Add(Entity);
            DB.SaveChanges();
            return Entity.ID;
        }
        //Test Login valid
        public string LoginValid(string userName,string password)
        {
            var result = DB.Users.SingleOrDefault(x=>x.UserName==userName);//Tra ve 1duy nhat 1 record
            if(result!=null)
            {
               
                if(result.Password!=password)
                {
                    return " Password Invalid!";
                }

                else if (result.Status == false)
                {
                    return " Acount Is clocked!";
                }
                else
                {
                    return "Sussecfully!";
                }
            }
            return "UserName Invalid!";
        }
        public User GetByID(string username)
        {
            return DB.Users.SingleOrDefault(x => x.UserName == username);
        }

    }
}
//View

@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/Admin/Views/Shared/_LayoutAdmin.cshtml";
}
@model OnlineShop.EF.User



<h2>Edit Member</h2>

@using (Html.BeginForm("Edit", "User", FormMethod.Post))
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4>User</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.UserName, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.TextBoxFor(model => model.UserName, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.UserName, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Password, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.TextBoxFor(model => model.Password, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Password, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Status, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Status, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Status, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div>
                <button type="submit" class="btn btn-default">Tแบกo</button>
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>


Output:
Line 2: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'OnlineShop'
Line 3: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'OnlineShop'
Line 4: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'System'
Line 5: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'System'
Line 6: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'System'
Line 7: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'System'
Line 8: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'System'
Line 9: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PagedList'
Line 11: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'OnlineShop'
Line 56: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'System'
Line 57: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'System'
Line 58: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'System'
Line 59: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'System'
Line 60: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PagedList'
Line 62: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'OnlineShop'
Line 139: error: stray '@' in program
Line 139: error: expected identifier or '(' before '{' token
Line 143: error: stray '@' in program
Line 143: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'OnlineShop'
Line 149: error: stray '@' in program
Line 151: error: stray '@' in program
Line 156: error: stray '@' in program
Line 156: error: stray '@' in program
Line 158: error: stray '@' in program
Line 158: error: stray '@' in program
Line 160: error: stray '@' in program
Line 160: error: stray '@' in program
Line 161: error: stray '@' in program
Line 161: error: stray '@' in program
Line 166: error: stray '@' in program
Line 166: error: stray '@' in program
Line 168: error: stray '@' in program
Line 168: error: stray '@' in program
Line 169: error: stray '@' in program
Line 169: error: stray '@' in program
Line 174: error: stray '@' in program
Line 174: error: stray '@' in program
Line 176: error: stray '@' in program
Line 176: error: stray '@' in program
Line 177: error: stray '@' in program
Line 177: error: stray '@' in program
Line 183: error: stray '\341' in program
Line 183: error: stray '\272' in program
Line 183: error: stray '\241' in program
Line 189: error: expected identifier or '(' before '<' token
Line 190: error: stray '@' in program


Create a new paste based on this one


Comments: