public async Task <IActionResult> PutAssigned(int id, Assigned assigned) { if (id != assigned.AssignedID) { return(BadRequest()); } _context.Entry(assigned).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AssignedExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// ReSharper disable once TooManyDependencies public Select(IBody <TIn> body, IStores <TOut> stores, Func <TIn, TOut> select, Assigned <uint> limit) { _body = body; _stores = stores; _select = select; _limit = limit; }
public async Task <IActionResult> Edit(int id, [Bind("AssignedID,StaffID,Project_Code")] Assigned assigned) { if (id != assigned.AssignedID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(assigned); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AssignedExists(assigned.AssignedID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Project_Code"] = new SelectList(_context.Projects, "Project_Code", "Project_Code", assigned.Project_Code); ViewData["StaffID"] = new SelectList(_context.Staffs, "StaffID", "Staff_fullName", assigned.StaffID); return(View(assigned)); }
public async Task <Assigned> MutateAsync(Mutation mutation, CancellationToken cancellationToken = default(CancellationToken)) { var request = BeforeMutate(mutation); var(conn, callOptions) = _client.AnyConnection(); callOptions = callOptions.WithCancellationToken(cancellationToken); try { Assigned ag = await conn.Client.MutateAsync(request, callOptions); return(AfterMutate(request, ag)); } catch (Exception ex) { try { // Since a mutation error occurred, the txn should no longer be used // (some mutations could have applied but not others, but we don't know // which ones). Discarding the transaction enforces that the user // cannot use the txn further. await DiscardAsync(); } finally { CheckAndThrowException(ex); } } return(null); }
/// <summary> /// Allows data stored on dgraph instances to be modified. The fields in Mutation come in pairs, /// set and delete. Mutations can either be encoded as JSON or as RDFs. /// /// <para/>If <see cref="Mutation.CommitNow"/> is set, then this call will result in the transaction being committed. /// In this case, an explicit call to <see cref="Transaction.CommitAsync"/> doesn't need to subsequently be made. /// /// </summary> /// <param name="mutation">a Mutation protocol buffer object representing the mutation.</param> /// <returns>an Assigned protocol buffer object. Its call will result in the transaction being committed. In this case, an explicit call to Transaction#commit doesn't need to subsequently be made.</returns> public Assigned Mutate(Mutation mutation) { var request = BeforeMutate(mutation); var(conn, callOptions) = _client.AnyConnection(); try { Assigned ag = conn.Client.Mutate(request, callOptions); return(AfterMutate(request, ag)); } catch (Exception ex) { try { // Since a mutation error occurred, the txn should no longer be used // (some mutations could have applied but not others, but we don't know // which ones). Discarding the transaction enforces that the user // cannot use the txn further. Discard(); } finally { CheckAndThrowException(ex); } } return(null); }
// ReSharper disable once TooManyDependencies public Concatenation(IBody <T> body, ISequence <T> others, IStores <T> stores, Assigned <uint> limit) { _body = body; _others = others; _stores = stores; _limit = limit; }
// ReSharper disable once TooManyDependencies public Where(Func <T, bool> where, uint start, Assigned <uint> until, Assigned <uint> limit) { _where = where; _start = start; _until = until; _limit = limit; }
public void Assign(EmployeeComponent employee, Recipe recipe) { this.Log($"Assignment assigning {employee} to {recipe}"); if (!employee) { this.Log($"Assignment can't assign: Employee was null", LogType.Warning); return; } if (!recipe) { this.Log($"Assignment can't assign: Recipe was null", LogType.Warning); return; } if (!Company.IsEmployed(employee)) { this.Log($"Assignment can't assign: Employee was not employed", LogType.Warning); return; } RegisterEmployee(employee); if (!IsAssignable(employee)) { this.Log($"Assignment can't assign: Employee was not assignable", LogType.Warning); return; } Unassign(employee); Assignments[employee] = recipe; Assigned?.Invoke(this, new AssignmentEventArgs(employee, recipe)); }
// ReSharper disable once TooManyDependencies public InlineProjection(IBody <TIn> body, Copy <TIn, TOut> apply, IStores <TOut> stores, Assigned <uint> limit) { _body = body; _apply = apply; _stores = stores; _limit = limit; }
public ActionResult DeleteConfirmed(string id) { Assigned assigned = db.Assigneds.Find(id); db.Assigneds.Remove(assigned); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult <Assigned> > PostAssigned(Assigned assigned) { _context.Assigneds.Add(assigned); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetAssigned), new { id = assigned.AssignedID }, assigned)); //return CreatedAtAction("GetAssigned", new { id = assigned.AssignedID }, assigned); }
public bool DeleteAssigned(User user) { if (!Assigned.Contains(user)) { return(false); } Assigned.Remove(user); return(true); }
// ReSharper disable once TooManyDependencies public Union(IBody <T> body, ISequence <T> others, IEqualityComparer <T> comparer, IStores <T> stores, Assigned <uint> limit) { _body = body; _others = others; _comparer = comparer; _stores = stores; _limit = limit; }
// ReSharper disable once TooManyDependencies public SelectMany(IBody <TIn> body, Func <TIn, IEnumerable <TOut> > project, IStores <TOut> stores, IIterate <TOut> iterate, Assigned <uint> limit) { _body = body; _project = project; _stores = stores; _iterate = iterate; _limit = limit; }
public ActionResult Edit([Bind(Include = "Id,MacAddress,Issued")] Assigned assigned) { if (ModelState.IsValid) { db.Entry(assigned).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(assigned)); }
public ActionResult Create([Bind(Include = "Id,MacAddress,Issued")] Assigned assigned) { if (ModelState.IsValid) { db.Assigneds.Add(assigned); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(assigned)); }
internal (IDgraphClientInternal, Assigned) MinimalClientForMutation() { var client = Substitute.For <IDgraphClientInternal>(); var assigned = new Assigned(); assigned.Context = new TxnContext();; client.Mutate(Arg.Any <Api.Mutation>()).Returns(assigned); return(client, assigned); }
/// <summary> /// Adds a world entity to the list of assigned entities. /// </summary> /// <param name="name">The name of the world entity.</param> /// <param name="raiseChangeEvent">Whether or not to raise the assigned change event.</param> public virtual void AddAssigned(string name, bool raiseChangeEvent = true) { if (!Assigned.Contains(name) && Assigned.Count < MaxAssigned) { Assigned.Add(name); if (raiseChangeEvent) { RaiseChangeEvent(WorldEntityListType.Assigned); } } }
/// <summary> /// Removes a world entity from the list of assigned entities. /// </summary> /// <param name="name">The name of the world entity.</param> /// <param name="raiseChangeEvent">Whether or not to raise the assigned change event.</param> public virtual void RemoveAssigned(string name, bool raiseChangeEvent = true) { if (Assigned.Contains(name)) { Assigned.Remove(name); if (raiseChangeEvent) { RaiseChangeEvent(WorldEntityListType.Assigned); } } }
public bool AddAssigned(User user) { if (!Assigned.Contains(user)) { return(false); } if (Assigned.Count == assignedLimit) { return(false); } Assigned.Add(user); return(true); }
private Assigned AfterMutate(Mutation mu, Assigned ag) { _mutated = true; if (mu.CommitNow) { _finished = true; } MergeContext(ag.Context); return(ag); }
public async Task <IActionResult> Create([Bind("AssignedID,StaffID,Project_Code")] Assigned assigned) { if (ModelState.IsValid) { _context.Add(assigned); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Project_Code"] = new SelectList(_context.Projects, "Project_Code", "Project_Code", assigned.Project_Code); ViewData["StaffID"] = new SelectList(_context.Staffs, "StaffID", "Staff_fullName", assigned.StaffID); return(View(assigned)); }
// GET: Assigned/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Assigned assigned = db.Assigneds.Find(id); if (assigned == null) { return(HttpNotFound()); } return(View(assigned)); }
// Method to fetch all tasks with member avatar added in Task Repo for code brevity public async Task <IEnumerable <TaskVm> > GetTasksWithMemberAvatar(CancellationToken cancellationToken = default) { return(await(from task in _db.Tasks join member in _db.Members on task.AssignedToId equals member.Id into Assigned from assignedMember in Assigned.DefaultIfEmpty() select new TaskVm { Id = task.Id, Subject = task.Subject, IsComplete = task.IsComplete, AssignedToId = task.AssignedToId, Avatar = assignedMember.Avatar ?? "" }).ToListAsync(cancellationToken)); }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="Microsoft.Rest.ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (Active != null) { Active.Validate(); } if (Assigned != null) { Assigned.Validate(); } if (LastKnownGood != null) { LastKnownGood.Validate(); } }
/// <summary> /// Adds a piece of equipment to the assigned list. /// </summary> /// <param name="name">The name of the equipment to assign.</param> /// <param name="raiseChangeEvent">Whether or not the raise an event about the change.</param> public override void AddAssigned(string name, bool raiseChangeEvent = true) { var equipmentObject = GetEntityObject(name) as Equipment; var slot = equipmentObject.EquipmentSlot; var listToRemove = new List <string>(); foreach (var equipment in Assigned) { var checkEquipment = GetEntityObject(equipment) as Equipment; var checkSlot = checkEquipment.EquipmentSlot; if (slot == EquipmentSlot.TwoHand) { if (checkSlot == EquipmentSlot.LeftHand || checkSlot == EquipmentSlot.RightHand) { listToRemove.Add(equipment); } } else { if (checkSlot == slot || (checkSlot == EquipmentSlot.TwoHand && (slot == EquipmentSlot.LeftHand || slot == EquipmentSlot.RightHand))) { listToRemove.Add(equipment); } } } foreach (var equipment in listToRemove) { RemoveAssigned(equipment, false); } if (!Assigned.Contains(name) && Assigned.Count < MaxAssigned) { Assigned.Add(name); if (raiseChangeEvent) { RaiseChangeEvent(WorldEntityListType.Assigned); } } }
/// <summary> /// Compares this <see cref="Assigned{T}" /> value to another value. /// </summary> /// <param name="other"> /// The second <see cref="Assigned{T}" /> for comparison. /// </param> /// <returns> /// <c>true</c> if both <see cref="Assigned{T}" /> values are equal. /// </returns> public bool Equals(Assigned <T>?other) { if (other is null) { return(!_hasValue); } if (!_hasValue && !other._hasValue) { return(true); } if (_hasValue != other._hasValue) { return(false); } return(Equals(Value, other.Value)); }
internal bool EqualsProjectAndDownloadTime(WorkUnit other) { if (other == null) { return(false); } // if the Projects are known if (this.HasProject() && other.HasProject()) { // equals the Project and Assigned if (this.EqualsProject(other) && Assigned.Equals(other.Assigned)) { return(true); } } return(false); }
/// <summary> /// Serves as a hash function for a particular type. /// </summary> /// <returns> /// A hash code for the current <see cref="T:System.Object"/>. /// </returns> /// <filterpriority>2</filterpriority> public override int GetHashCode() { unchecked { int result = Id; result = (result * 397) ^ (State != null ? State.GetHashCode() : 0); result = (result * 397) ^ StateEnum.GetHashCode(); result = (result * 397) ^ Project; result = (result * 397) ^ Run; result = (result * 397) ^ Clone; result = (result * 397) ^ Gen; result = (result * 397) ^ (Core != null ? Core.GetHashCode() : 0); result = (result * 397) ^ (UnitId != null ? UnitId.GetHashCode() : 0); result = (result * 397) ^ (PercentDone != null ? PercentDone.GetHashCode() : 0); result = (result * 397) ^ TotalFrames; result = (result * 397) ^ FramesDone; result = (result * 397) ^ (Assigned != null ? Assigned.GetHashCode() : 0); result = (result * 397) ^ (AssignedDateTime.HasValue ? AssignedDateTime.Value.GetHashCode() : 0); result = (result * 397) ^ (Timeout != null ? Timeout.GetHashCode() : 0); result = (result * 397) ^ (TimeoutDateTime.HasValue ? TimeoutDateTime.Value.GetHashCode() : 0); result = (result * 397) ^ (Deadline != null ? Deadline.GetHashCode() : 0); result = (result * 397) ^ (DeadlineDateTime.HasValue ? DeadlineDateTime.Value.GetHashCode() : 0); result = (result * 397) ^ (WorkServer != null ? WorkServer.GetHashCode() : 0); result = (result * 397) ^ (WorkServerIPAddress != null ? WorkServerIPAddress.GetHashCode() : 0); result = (result * 397) ^ (CollectionServer != null ? CollectionServer.GetHashCode() : 0); result = (result * 397) ^ (CollectionServerIPAddress != null ? CollectionServerIPAddress.GetHashCode() : 0); result = (result * 397) ^ (WaitingOn != null ? WaitingOn.GetHashCode() : 0); result = (result * 397) ^ Attempts; result = (result * 397) ^ (NextAttempt != null ? NextAttempt.GetHashCode() : 0); result = (result * 397) ^ (NextAttemptTimeSpan.HasValue ? NextAttemptTimeSpan.Value.GetHashCode() : 0); result = (result * 397) ^ Slot; result = (result * 397) ^ (Eta != null ? Eta.GetHashCode() : 0); result = (result * 397) ^ (EtaTimeSpan.HasValue ? EtaTimeSpan.Value.GetHashCode() : 0); result = (result * 397) ^ Ppd.GetHashCode(); result = (result * 397) ^ (Tpf != null ? Tpf.GetHashCode() : 0); result = (result * 397) ^ (TpfTimeSpan.HasValue ? TpfTimeSpan.Value.GetHashCode() : 0); result = (result * 397) ^ BaseCredit.GetHashCode(); result = (result * 397) ^ CreditEstimate.GetHashCode(); result = (result * 397) ^ (Description != null ? Description.GetHashCode() : 0); return(result); } }
public override string ToString() { var result = new StringBuilder(); result.Append(SonarPagingQuery.ToString()); SonarHelpers.AppendUrl(result, "issues", IssuesKeys); if (Assigned != null) { SonarHelpers.AppendUrl(result, "assigned", Assigned.ToString().ToLowerInvariant()); } SonarHelpers.AppendUrl(result, "statuses", Statuses); SonarHelpers.AppendUrl(result, "tags", Tags); if (CreatedAfter != null) { SonarHelpers.AppendUrl(result, "createdAfter", WebUtility.UrlEncode(SonarHelpers.FormatDateForSonarIso8601(CreatedAfter.Value))); // when scanning for createdAfter, automatically sort by created date SonarHelpers.AppendUrl(result, "s", "CREATION_DATE"); SonarHelpers.AppendUrl(result, "asc", "true"); } if (CreatedAt != null) { SonarHelpers.AppendUrl(result, "createdAt", WebUtility.UrlEncode(SonarHelpers.FormatDateForSonarIso8601(CreatedAt.Value))); } if (CreatedBefore != null) { SonarHelpers.AppendUrl(result, "createdBefore", WebUtility.UrlEncode(SonarHelpers.FormatDateForSonarIso8601(CreatedBefore.Value))); } SonarHelpers.AppendUrl(result, "additionalFields", AdditionalFields); SonarHelpers.AppendUrl(result, "assignees", Assignees); SonarHelpers.AppendUrl(result, "authors", Authors); SonarHelpers.AppendUrl(result, "componentKeys", ComponentKeys); SonarHelpers.AppendUrl(result, "componentUuids", ComponentUuids); SonarHelpers.AppendUrl(result, "severities", Severities); SonarHelpers.AppendUrl(result, "rules", Rules); SonarHelpers.AppendUrl(result, "projectKeys", ProjectKeys); SonarHelpers.AppendUrl(result, "resolved", Resolved.ToString().ToLowerInvariant()); return(result.Length > 0 ? "?" + result : string.Empty); }