Example #1
0
 public Client()
 {
     ClientType        = new ClientType();
     Orders            = new List <Order>();
     MailingAddress    = new MailingAddress();
     PostOffice        = new PostOffice();
     District          = new District();
     Upazilla          = new Upazilla();
     Division          = new Division();
     Branch            = new Branch();
     ClientAttachments = new List <ClientAttachment>();
 }
 public IActionResult AddData(Upazilla upazilla)
 {
     try {
         if (upazilla == null)
         {
             return(NotFound());                   //404
         }
         _dataContext.Add(upazilla);
         _dataContext.SaveChanges();
         return(CreatedAtRoute("GetUpazilla", new { id = upazilla.Id }, upazilla)); //201
     } catch (System.Exception) {
         return(BadRequest());
     }
 }
 public IActionResult UpdateData(int id, Upazilla upazilla)
 {
     try {
         if (id != upazilla.Id)
         {
             return(BadRequest("Invalid Data"));                    // validation status 400
         }
         var data = _dataContext.Upazillas.FirstOrDefault(x => x.Id == id);
         if (data == null)
         {
             return(NotFound());               // 404
         }
         data.Name = upazilla.Name;
         _dataContext.Upazillas.Update(data);
         _dataContext.SaveChanges();
         return(NoContent());                 // 204
     } catch (System.Exception) {
         return(BadRequest("Error occured")); //400
     }
 }