public void TestCompanyModel() { var now = DateTime.Now; var company = new Company { Id = 1, CreationDate = now, Name = "firstName", Cvr = 100, Address = "address", Zip = 200, City = "city", Phone = 12345678, Email = "[email protected]", ResponseTime = 300 }; var dto = CompanyDto.Create(company); Assert.AreEqual(company.Id, dto.Id); Assert.AreEqual(company.CreationDate, dto.CreationDate); Assert.AreEqual(company.Name, dto.Name); Assert.AreEqual(company.Cvr, dto.Cvr); Assert.AreEqual(company.Address, dto.Address); Assert.AreEqual(company.Zip, dto.Zip); Assert.AreEqual(company.City, dto.City); Assert.AreEqual(company.Phone, dto.Phone); Assert.AreEqual(company.Email, dto.Email); Assert.AreEqual(company.ResponseTime, dto.ResponseTime); }
public HttpResponseMessage PostCompany(Company company) { company.CreationDate = DateTime.Now; if (ModelState.IsValid) { this.RepositoryContext.CompanyRepository.Add(company); this.RepositoryContext.Save(); var response = Request.CreateResponse(HttpStatusCode.Created, CompanyDto.Create(company)); return response; } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
public HttpResponseMessage PutCompany(int id, Company company) { if (ModelState.IsValid && id == company.Id) { this.RepositoryContext.CompanyRepository.Update(id, company); try { this.RepositoryContext.Save(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.NotFound); } return Request.CreateResponse(HttpStatusCode.OK); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
/// <summary> /// Create a new Company object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="creationDate">Initial value of the CreationDate property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="cvr">Initial value of the Cvr property.</param> /// <param name="address">Initial value of the Address property.</param> /// <param name="zip">Initial value of the Zip property.</param> /// <param name="city">Initial value of the City property.</param> /// <param name="phone">Initial value of the Phone property.</param> /// <param name="email">Initial value of the Email property.</param> /// <param name="responseTime">Initial value of the ResponseTime property.</param> public static Company CreateCompany(global::System.Int32 id, global::System.DateTime creationDate, global::System.String name, global::System.Int32 cvr, global::System.String address, global::System.Int32 zip, global::System.String city, global::System.Int32 phone, global::System.String email, global::System.Int32 responseTime) { Company company = new Company(); company.Id = id; company.CreationDate = creationDate; company.Name = name; company.Cvr = cvr; company.Address = address; company.Zip = zip; company.City = city; company.Phone = phone; company.Email = email; company.ResponseTime = responseTime; return company; }
/// <summary> /// Deprecated Method for adding a new object to the Company EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCompany(Company company) { base.AddObject("Company", company); }