public async Task <ActionResult <Contractor> > Edit([FromBody] Contractor updated, int id) { try { Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>(); updated.CreatorId = userInfo.Id; updated.Id = id; return(Ok(_service.Edit(updated))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Address,City,State,ZipCode,IdentityUserId,SpotID")] Contractor contractor) { if (ModelState.IsValid) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); contractor.IdentityUserId = userId; _context.Add(contractor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdentityUserId"] = new SelectList(_context.Users, "Id", "Id", contractor.IdentityUserId); return(View(contractor)); }
public async Task CanSaveOrUpdate() { var entity = new Contractor { Name = "John Doe" }; var res = await _repo.SaveOrUpdateAsync(entity).ConfigureAwait(false); res.IsTransient().Should().BeFalse(); entity.Name = "John Doe Jr"; res = await _repo.SaveOrUpdateAsync(entity).ConfigureAwait(false); res.Name.Should().Be("John Doe Jr"); }
public async Task <ActionResult> Edit([Bind(Include = "ContractorID,CustomerID,BusinessTypeID,CompanyName,TaxIdNumber,CountryID,StateID,City,Address,PhoneNumber,EmergencyPhoneNumber,Email,CreationDate,CreationUser,ModifiedDate,ModifiedUser")] Contractor contractor) { if (ModelState.IsValid) { contractor.ModifiedDate = DateTime.UtcNow; contractor.ModifiedUser = System.Web.HttpContext.Current.User.Identity.Name; await contractorRepository.UpdateAsync(contractor); return(RedirectToAction("Index")); } ViewBag.BusinessTypeID = new SelectList(businessTypeRepository.BusinessTypes(base.CurrentCustomerID), "BusinessTypeID", "BusinessTypeCode", contractor.BusinessTypeID); ViewBag.CountryID = new SelectList(localizationRepository.Countries(), "CountryID", "CountryName", contractor.CountryID); ViewBag.StateID = new SelectList(localizationRepository.States(), "StateID", "StateName", contractor.StateID); return(View(contractor)); }
public void CanVerifyThatDuplicateExistsDuringValidationProcess() { var contractor = new Contractor { Name = @"Codai" }; ValidationContext validationContext = ValidationContextFor(contractor); IEnumerable <ValidationResult> invalidValues = contractor.ValidationResults(validationContext); foreach (ValidationResult invalidValue in invalidValues) { Debug.WriteLine(invalidValue.ErrorMessage); } contractor.IsValid(validationContext).Should().BeFalse(); }
private void UpdateContractor(Contractor item, Contractor editedItem) { item.Name = (editedItem.Name ?? String.Empty).Trim(); item.Code = (editedItem.Code ?? String.Empty).Trim(); item.Phone = (editedItem.Phone ?? String.Empty).Trim(); item.Fax = (editedItem.Fax ?? String.Empty).Trim(); item.Email = (editedItem.Email ?? String.Empty).Trim(); item.Region = (editedItem.Region ?? String.Empty).Trim(); item.ActualAddress = (editedItem.ActualAddress ?? String.Empty).Trim(); item.Comment = (editedItem.Comment ?? String.Empty).Trim(); item.ResponsibleId = editedItem.ResponsibleId; item.ContractorTypeId = editedItem.ContractorTypeId; item.ContactPersonName = editedItem.ContactPersonName; item.MarginAbs = editedItem.MarginAbs; }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Contractor = await _context.Contractor.FirstOrDefaultAsync(m => m.Contractorid == id); if (Contractor == null) { return(NotFound()); } return(Page()); }
public void CanVerifyThatDuplicateExistsDuringValidationProcess() { Contractor contractor = new Contractor() { Name = "Codai" }; IEnumerable <IValidationResult> invalidValues = contractor.ValidationResults(); Assert.That(contractor.IsValid(), Is.False); foreach (IValidationResult invalidValue in invalidValues) { Debug.WriteLine(invalidValue.Message); } }
// GET: Contractors/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Contractor contractor = db.Contractors.Find(id); if (contractor == null) { //return HttpNotFound(); return(View("ErrorView")); } return(View(contractor)); }
public async Task WhenEntityWithDuplicateIntIdExists_Should_MarkEntityAsInvalid() { var contractor = new Contractor { Name = "codai" }; await SaveAndEvict(contractor, CancellationToken.None); var duplicateContractor = new Contractor { Name = "codai" }; duplicateContractor.IsValid(ValidationContextFor(duplicateContractor)) .Should().BeFalse(); }
public void CalculateWeeklySalaryForContractorTest_70wage55hoursReturns3850Dollars() { int weeklyHours = 55; int wage = 70; int salary = weeklyHours * wage; Contractor employee = new Contractor(); string expectedResponse = String.Format("This HAPPY CONTRACTOR worked {0} hrs. " + "Paid for {0} hrs at $ {1}" + "/hr = ${2} ", weeklyHours, wage, salary); string response = employee.CalculateWeeklySalary(weeklyHours, wage); Assert.AreEqual(response, expectedResponse); }
private Contractor MapObject(SqlDataReader oReader) { Contractor oContractor = new Contractor(); oContractor.ContractorID = (int)oReader["ContractorID"]; oContractor.ContractorName = oReader["ContractorName"].ToString(); oContractor.CompanyName = oReader["CompanyName"].ToString(); oContractor.Email = oReader["Email"].ToString(); oContractor.Mobile = oReader["Mobile"].ToString(); oContractor.ContractorType = (EnumContractorType)oReader["ContractorType"]; oContractor.Code = oReader["Code"].ToString(); oContractor.Address = oReader["Address"].ToString(); oContractor.ContractorTypeInInt = (int)oReader["ContractorType"]; return(oContractor); }
public void CalculateWeeklySalaryForContractorTest_70wage55hoursDoesNotReturnCorrectString() { int weeklyHours = 55; int wage = 70; int salary = weeklyHours * wage; Employee e = new Contractor(); string expectedResponse = String.Format($"Problem 2-This HAPPY CONTRACTOR worked {weeklyHours} hrs. " + $"Paid for {weeklyHours} hrs at $ {wage}" + $"/hr = ${salary} "); string response = e.CalculateWeeklySalary(weeklyHours, wage); Assert.NotEqual(response, expectedResponse); }
public ActionResult Create(Contractor contractor) { try { var userLoggedIn = User.Identity.GetUserId(); contractor.ApplicationId = userLoggedIn; db.Contractors.Add(contractor); db.SaveChanges(); return(RedirectToAction("Details", "Contractors", contractor)); } catch { return(View()); } }
public ActionResult ConfirmDelete(string Id) { Contractor contractorToDelete = context.Find(Id); if (contractorToDelete == null) { return(HttpNotFound()); } else { context.Delete(Id); context.Commit(); return(RedirectToAction("Index")); } }
public async Task <ActionResult <Contractor> > CreateOne([FromBody] Contractor newContractor) { try { Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>(); newContractor.CreatorId = userInfo.Id; newContractor.Creator = userInfo; return(Ok(_cservice.CreateOne(newContractor))); } catch (System.Exception err) { return(BadRequest(err.Message)); } }
static void Main(string[] args) { const int hours = 50, wage = 70; Employee emp = new Employee(); emp.CalculateWeeklySalary(hours, wage); // Polymorphism Contractor cont = new Contractor(); cont.CalculateWeeklySalary(hours, wage); // Polymorphism Console.WriteLine("Press any key to continue .........."); Console.ReadKey(); }
public ActionResult Create(Contractor Contractor) { if (ModelState.IsValid) { //if Contractor does not exist yet Contractor.ContractorID = Guid.NewGuid(); db.Contractors.InsertOnSubmit(Contractor); db.SubmitChanges(); return(RedirectToAction("Index")); } return(View(Contractor)); }
public async Task <GetChatRoomsVm> Handle(GetChatRoomsQuery request, CancellationToken cancellationToken) { User currentUser = await _context.User .Where(x => x.UserGuid == Guid.Parse(_currentUser.NameIdentifier)) .SingleOrDefaultAsync(cancellationToken); if (currentUser == null) { return(new GetChatRoomsVm() { Message = "کاربر مورد نظر یافت نشد", State = (int)GetChatRoomState.UserNotFound }); } Contractor contractor = await _context.Contractor .SingleOrDefaultAsync(x => x.UserId == currentUser.UserId, cancellationToken); if (contractor == null) { return(new GetChatRoomsVm() { Message = "سرویس دهنده مورد نظر یافت نشد", State = (int)GetChatRoomState.ContractorNotFound }); } List <GetChatRoomsDto> orderRequests = await _context.OrderRequest .Where(x => x.ContractorId == contractor.ContractorId && x.IsAllow) .ProjectTo <GetChatRoomsDto>(_mapper.ConfigurationProvider) .ToListAsync(cancellationToken); if (orderRequests.Count <= 0) { return(new GetChatRoomsVm() { Message = "درخواست سفارشی برای کاربر مورد نظر یافت نشد", State = (int)GetChatRoomState.NotAnyChatRoomsFound }); } return(new GetChatRoomsVm() { Message = "عملیات موفق آمیز", State = (int)GetChatRoomState.Success, ChatRooms = orderRequests }); }
public async Task <bool> Handle(CreateContractorCommand message) { // Add/Update the Buyer AggregateRoot // DDD patterns comment: Add child entities and value-objects through the Contractor Aggregate-Root // methods and constructor so validations, invariants and business logic // make sure that consistency is preserved across the whole aggregate var cardTypeId = message.CardTypeId != 0 ? message.CardTypeId : 1; var buyerGuid = _identityService.GetUserIdentity(); var buyer = await _buyerRepository.FindAsync(buyerGuid); if (buyer == null) { buyer = new Buyer(buyerGuid); } var payment = buyer.AddPaymentMethod(cardTypeId, $"Payment Method on {DateTime.UtcNow}", message.CardNumber, message.CardSecurityNumber, message.CardHolderName, message.CardExpiration); _buyerRepository.Add(buyer); await _buyerRepository.UnitOfWork .SaveChangesAsync(); // Create the Contractor AggregateRoot // DDD patterns comment: Add child entities and value-objects through the Contractor Aggregate-Root // methods and constructor so validations, invariants and business logic // make sure that consistency is preserved across the whole aggregate var Contractor = new Contractor(buyer.Id, payment.Id, new Address(message.Street, message.City, message.State, message.Country, message.ZipCode)); foreach (var item in message.ContractorItems) { Contractor.AddContractorItem(item.ProductId, item.ProductName, item.UnitPrice, item.Discount, item.PictureUrl, item.Units); } _ContractorRepository.Add(Contractor); var result = await _ContractorRepository.UnitOfWork .SaveChangesAsync(); return(result > 0); }
static void Main(string[] args) { Employee employee = new Employee("Goran", "Turundzov", Role.Other, 500); SalesPerson sitkac = new SalesPerson("Zoran", "Turundzov", 2003); Manager gazda = new Manager("Elon", "Musk", 5000); sitkac.AddSuccessRevenue(400); gazda.AddBonus(5230); sitkac.AddSuccessRevenue(3000); Contractor gradba = new Contractor("Cile", "Cilevski", 60, 150, gazda); Console.WriteLine(gradba.GetInfo()); Console.WriteLine(gradba.GetSalary()); Console.WriteLine(gradba.CurrentPosition()); }
public void CalculateWeeklySalaryForContractorTest_70wage55hoursDoesNotReturnCorrectString() { // Arrange int weeklyHours = 55; int wage = 70; int salary = weeklyHours * wage; Contractor e = new Contractor(); string expectedResponse = String.Format("Problem 2 - This HAPPY CONTRACTOR worked {0} hrs. " + "Paid for {0} hrs at $ {1}" + "/hr = ${2} ", weeklyHours, wage, salary); // Act string response = e.CalculateWeeklySalary(weeklyHours, wage); // Assert Assert.AreNotEqual(expectedResponse, response); }
public async Task <ActionResult <Contractor> > Create([FromBody] Contractor newContractor) { try { Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>(); newContractor.CreatorId = userInfo.Id; Contractor created = _cs.Create(newContractor); created.Creator = userInfo; return(Ok(created)); } catch (System.Exception) { throw; } }
public ActionResult Accept(int?id) { Contractor bookingRoom = db.Contractors.Where(p => p.ContractorId == id).FirstOrDefault(); bookingRoom.Contractor_Availability = "Unavailable"; AssignContractor booking = db.AssignContractors.Where(p => p.Contractor.ContractorName == bookingRoom.ContractorName).FirstOrDefault(); booking.Status = "Job Accepted"; db.Entry(booking).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
internal Contractor EditOne(Contractor editContractor) { Contractor contractor = GetOne(editContractor.Id); if (contractor == null) { throw new SystemException("INVALID ID"); } else { editContractor.Age = editContractor.Age != null ? editContractor.Age : contractor.Age; editContractor.Name = editContractor.Name != null ? editContractor.Name : contractor.Name; editContractor.Salary = editContractor.Salary != null ? editContractor.Salary : contractor.Salary; return(_crepo.EditOne(editContractor)); } }
// GET: Contractors/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Contractor contractor = db.Contractors.Find(id); if (contractor == null) { return(HttpNotFound()); } ViewBag.ContactId = new SelectList(db.Contacts, "Id", "Name", contractor.ContactId); ViewBag.ContractorAddressId = new SelectList(db.ContractorAddresses, "Id", "Address1", contractor.ContractorAddressId); return(View(contractor)); }
public void Delete(Guid id) { Contractor contractor = db.Contractors.Find(id); if (contractor != null) { db.Entry(contractor).State = EntityState.Deleted; } ContractorAddress adress = db.ContractorAddreses.Find(id); if (adress != null) { db.Entry(adress).State = EntityState.Deleted; } }
static void Main(string[] args) { var employee = new Employee(); employee.FirstName = "Jason"; employee.LastName = "Robert"; employee.EmployeeNumber = 12342; Console.WriteLine(employee.GetFullName()); var contractor = new Contractor(); contractor.FirstName = "Dafy"; contractor.LastName = "Duck"; // EmployeeNumber is not avail here Console.WriteLine(contractor.GetFullName()); }
public bool ModifyGame(HGame game) { bool possiblyModified = false; ModuleItem[] moduleItems = Contractor.GetModuleItems(); foreach (ModuleItem moduleItem in moduleItems) { if (moduleItem.IsInitialized && moduleItem.Extension != null) { moduleItem.Extension?.ModifyGame(game); possiblyModified = true; } } return(possiblyModified); }
public void CalculateWeeklySalaryForContractorTest_70wage55hoursReturns3850Dollars() { // Arrange int weeklyHours = 55; int wage = 70; int salary = wage * weeklyHours; Contractor c = new Contractor(); string expectedResponse = $"\nThis HAPPY CONTRACTOR worked {weeklyHours} hrs. " + $"Paid for {weeklyHours} hrs at $ {wage}" + $"/hr = ${salary} "; string response = c.CalculateWeeklySalary(weeklyHours, wage); // Assert Assert.AreEqual(response, expectedResponse); }
public static Contractor CreateContractor(int personId, int contratorCompanyId, int billingRate, int teamContactPersonId) { Contractor contractor = new Contractor(); contractor.PersonId = personId; contractor.ContratorCompanyId = contratorCompanyId; contractor.BillingRate = billingRate; contractor.TeamContactPersonId = teamContactPersonId; return contractor; }
public ContractorViewModel(Contractor contractor) { Contractor = contractor; ButtonContent = "Edytuj"; ButtonCommand = new RelayCommand(EditContractor); }
public ContractorWindow(Contractor contractor) { DataContext = new ContractorViewModel(contractor); ((ContractorViewModel)DataContext).RequestCloseWindow += (s, e) => Close(); }
public ExtensionInfo(string fileLocation, string hash, Contractor contractor) { Hash = hash; Contractor = contractor; FileLocation = fileLocation; }