public IHttpActionResult UpdateBlacklisting(int id, TMS_Blacklisting blacklisting)
        {
            if (!blacklisting.AccountId.HasValue)
            {
                return(Json(new { Msg = "0", Reason = "Account Id field cannot be empty!" }));
            }
            if (!blacklisting.BlacklistingDate.HasValue)
            {
                return(Json(new { Msg = "0", Reason = "Blacklisting Date field cannot be empty!" }));
            }
            if (blacklisting.CurrentStage == String.Empty)
            {
                return(Json(new { Msg = "0", Reason = "Current Stage field cannot be empty!" }));
            }
            if (blacklisting.Notes == String.Empty)
            {
                return(Json(new { Msg = "0", Reason = "Note field cannot be empty!" }));
            }

            //TODO: assign default values before inserting
            //blacklisting.CreationDate = DateTime.Now;

            if (!ModelState.IsValid)
            {
                return(Json(new { Msg = "0" }));
            }

            if (id != blacklisting.Id)
            {
                //return BadRequest();
                return(Json(new { Msg = "0" }));
            }

            try
            {
                int s = _blacklistingBll.Update(blacklisting);
                if (s == 1)
                {
                    return(Json(new { Msg = "1" }));
                }
                return(Json(new { Msg = "0" }));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DeleteBlacklistingExists(id))
                {
                    //return NotFound();
                    return(Json(new { Msg = "0", Reason = "Exception!" }));
                }
                else
                {
                    throw;
                }
            }
        }
        public IHttpActionResult Post(TMS_Blacklisting blacklisting)
        {
            if (!blacklisting.AccountId.HasValue)
            {
                return(Json(new { Msg = "0", Reason = "Account Id field cannot be empty!" }));
            }
            if (!blacklisting.BlacklistingDate.HasValue)
            {
                return(Json(new { Msg = "0", Reason = "Blacklisting Date field cannot be empty!" }));
            }
            if (blacklisting.CurrentStage == String.Empty)
            {
                return(Json(new { Msg = "0", Reason = "Current Stage field cannot be empty!" }));
            }
            if (blacklisting.Notes == String.Empty)
            {
                return(Json(new { Msg = "0", Reason = "Note field cannot be empty!" }));
            }

            //TODO: assign default values before inserting
            //blacklisting.CreationDate = DateTime.Now;

            if (ModelState.IsValid)
            {
                int c = _blacklistingBll.Insert(blacklisting);
                if (c == 1)
                {
                    return(Json(new { Msg = "1" }));
                }
                return(Json(new { Msg = "0" }));
            }
            else
            {
                return(Json(new { Msg = "0" }));
            }
        }
예제 #3
0
 public int Update(TMS_Blacklisting blacklisting)
 {
     return(_repository.Update(blacklisting));
 }
예제 #4
0
 public int Insert(TMS_Blacklisting blacklisting)
 {
     return(_repository.Insert(blacklisting));
 }