Esempio n. 1
0
        public HttpResponseMessage Put(string hashTag, Topic obj)
        {
            var payload = new HttpResponsePayload<Topic>();

            try
            {
                throw new NotImplementedException();
            }
            catch (Exception ex)
            {
                ExceptionHandler.Log(ex);
                payload.AssignExceptionErrors(ex);
            }

            // Return proper response message
            return Request.CreateResponse(payload.HttpStatusCode, payload);
        }
Esempio n. 2
0
        public bool Save(ref Topic obj)
        {
            bool result = false;
            if (obj != null)
            {
                if (!string.IsNullOrEmpty(obj.Tag))
                {
                    // Add to collection
                    context.Subjects.Add(obj);
                }
                else
                {
                    // Attach to collection
                    context.Subjects.Attach(obj);
                    context.Entry(obj).State = System.Data.EntityState.Modified;
                }

                // Commit changes
                result = context.SaveChanges() > 0;
            }

            return result;
        }
Esempio n. 3
0
        /// <summary>
        /// Subject validation
        /// </summary>
        /// <param name="obj"></param>
        public void Validate(Topic obj)
        {
            if (obj == null)
            {
                this.Errors.Add("00004", Resources.Errors.ERR00004);
                return;
            }

            if (string.IsNullOrEmpty(obj.Tag))
            {
                this.Errors.Add("00200", Resources.Errors.ERR00200);
            }

            if (obj.ContributorGuid == null || obj.ContributorGuid == Guid.Empty)
            {
                this.Errors.Add("00106", Resources.Errors.ERR00106);
            }

            if (obj.Description.Length > 4000)
            {
                this.Errors.Add("00201", Resources.Errors.ERR00201);
            }

            if (obj.Title.Length > 100)
            {
                this.Errors.Add("00202", Resources.Errors.ERR00202);
            }
        }