public IHttpActionResult PutCustomerMaster(long id, CustomerMaster customerMaster)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != customerMaster.cust_info_id)
            {
                return BadRequest();
            }

            //db.Entry(customerMaster).State = EntityState.Modified;
            db.InsertOrUpdate(customerMaster);
            try
            {
                db.Save();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerMasterExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Ejemplo n.º 2
0
        public void CanCustomerInsert()
        {
            int isSaved = 0;
            using (var context = new CustomerMasterRepository(new UnitOfWork()))
            {
                var cust = new CustomerMaster
                {
                    addr_city_nm = "Beerakuppam",
                    addr_ctry_nm = "India",
                    addr_zip_cde = "517589",
                    addr_state = "AP",
                    addr_ln_1_txt = "Nagalapuram (M),Chittoor(d)",
                    mid_nm = "",
                    frst_nm = "Kanakaiah",
                    last_nm = "Etipakam",
                    email_addr_txt = "*****@*****.**",
                    rec_crt_ts = DateTime.UtcNow,
                    rec_crt_by = "Test-Project-KK"
                };
                context.InsertOrUpdate(cust)
                ;

                isSaved = (int)cust.cust_info_id;

                isSaved = context.Save();

                Assert.AreEqual(1, isSaved);
            }
        }
        public IHttpActionResult PostCustomerMaster(CustomerMaster customerMaster)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.InsertOrUpdate(customerMaster);
            db.Save();

            return CreatedAtRoute("DefaultApi", new { id = customerMaster.cust_info_id }, customerMaster);
        }