Esempio n. 1
0
        public string Edit(FormDataCollection form)
        {
            string     retVal    = string.Empty;
            string     operation = form.Get("oper");
            int        id        = ConvertHelper.ToInt32(form.Get("SourceId"));
            SourceInfo info      = null;

            if (!string.IsNullOrEmpty(operation))
            {
                switch (operation)
                {
                case "edit":
                    info = SourceRepository.GetInfo(id);
                    if (info != null)
                    {
                        info.Name = form.Get("Name");

                        info.Code = form.Get("Code");

                        info.Description = form.Get("Description");


                        info.ChangedBy = UserRepository.GetCurrentUserInfo().UserID;

                        SourceRepository.Update(info);
                    }
                    break;

                case "add":
                    info = new SourceInfo
                    {
                        Name        = form.Get("Name"),
                        Code        = form.Get("Code"),
                        Description = form.Get("Description"),
                        CreatedBy   = UserRepository.GetCurrentUserInfo().UserID
                    };


                    SourceRepository.Create(info);
                    break;

                case "del":
                    SourceRepository.Delete(id, UserRepository.GetCurrentUserInfo().UserID);
                    break;

                default:
                    break;
                }
            }
            return(retVal);
        }
Esempio n. 2
0
 // GET api/<controller>/5
 public SourceInfo Get(int id)
 {
     return(SourceRepository.GetInfo(id));
 }