Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

409 conflict

public IHttpActionResult PostCanonical(Canonical canonical)
{
    if (!ModelState.IsValid)
    {
        return BadRequest(ModelState);
    }

    // Check for duplicate Canonical text for the same app name.
    if (db.IsDuplicateCanonical(canonical.AppName, canonical.Text))
    {
        // It's a duplicate.  Return an HTTP 409 Conflict error to let the client know.
        var original = db.CanonicalSentences.First(c => c.ID == canonical.ID);
        return new NegotiatedContentResult<T>(HttpStatusCode.Conflict, original, this);
    }

    db.CanonicalSentences.Add(canonical);
    db.SaveChanges();

    return CreatedAtRoute("DefaultApi", new { id = canonical.ID }, canonical);
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: loops in coding 
Csharp :: block wapalyzer from detecting codeigniter 
Csharp :: Maximize Print Preview 
Csharp :: check which activity in focus in android 
Csharp :: c# order by descending on 2 values 
Csharp :: c# 9.0 dynamic nedir 
Csharp :: c# delegates 
Csharp :: c# dictionary key set 
Csharp :: C# Implicitly typed variable 
Csharp :: set field in list linq 
Csharp :: c# excel fix first row 
Csharp :: .net core executenonqueryasync transaction 
Csharp :: anidate bucle in c# 
Csharp :: asp.net stop page jumping to top on click 
Csharp :: how to save in mongo different name field than model? c# 
Csharp :: get all the file from directory except txt in c# 
Csharp :: button commandfield commandargument pass textbox 
Csharp :: c# unzip all archive files inside directory 
Csharp :: asp.net core user.identity.name is null 
Csharp :: make tooltip disappear c# 
Csharp :: uity pause game 
Csharp :: Wait some seconds without blocking UI execution 
Csharp :: get last id ef 
Csharp :: entity save example in c# model first 
Csharp :: unity blender shadow messed up 
Csharp :: reversing linkedlist C# 
Csharp :: unity save slots 
Csharp :: ExceptionFilterAttribute exception-handler-middleware-not-catching 
Csharp :: c# interface implementation 
Csharp :: Cursor Invisibility 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =