Beispiel #1
0
        public string Edit(FormDataCollection form)
        {
            var retVal    = string.Empty;
            var operation = form.Get("oper");
            var id        = ConvertHelper.ToInt32(form.Get("LevelId"));

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

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

                        info.Priority = ConvertHelper.ToInt32(form.Get("Priority"));

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

                        LevelRepository.Update(info);
                    }
                    break;

                case "add":
                    info = new LevelInfo
                    {
                        Name        = form.Get("Name"),
                        Description = form.Get("Description"),
                        Priority    = ConvertHelper.ToInt32(form.Get("Priority")),
                        CreatedBy   = UserRepository.GetCurrentUserInfo().UserID
                    };

                    LevelRepository.Create(info);
                    break;

                case "del":
                    LevelRepository.Delete(id, UserRepository.GetCurrentUserInfo().UserID);
                    break;
                }
            }
            //StoreData._listLevel = LevelRepository.GetAll();
            return(retVal);
        }
Beispiel #2
0
 // GET api/<controller>/5
 public LevelInfo Get(int id)
 {
     return(LevelRepository.GetInfo(id));
 }