Exemplo n.º 1
0
        public ActionResult UpdateCompany(Company c)
        {
            var company = BLLUsers.AddOrUpdateCompany(c);

            BLLUsers.UpdateUserMainCompany(company.Id, User.Identity.GetUserId());
            return(RedirectToAction("Profil"));
        }
Exemplo n.º 2
0
        public ActionResult AskArbitrationValidation(int conflictId, Company company)
        {
            var conflict = BLLConflicts.GetConflictForUser(conflictId, User.Identity.GetId());


            var com = BLLUsers.AddOrUpdateCompany(company);

            BLLUsers.UpdateUserMainCompany(com.Id, User.Identity.GetId());

            var uic = conflict.UsersInConflicts.Where(c => c.IdUser == User.Identity.GetId()).FirstOrDefault();

            uic.HasAcceptedArbitration = true;
            BLLConflicts.UpdateUserInConflict(uic);

            conflict = BLLConflicts.GetFullConflict(conflictId);
            if (conflict.UsersInConflicts.All(c => c.HasAcceptedArbitration != null && c.HasAcceptedArbitration.Value) ||
                conflict.HasArbitralClause && conflict.UsersInConflicts.Any(c => c.HasAcceptedArbitration != null && c.HasAcceptedArbitration.Value) &&
                conflict.PaymentState == (int)PaymentStateEnum.Complete)
            {
                conflict.State = (int)ConflictState.ArbitrationReady;
                BLLConflicts.UpdateConflict(conflict);

                foreach (var item in conflict.UsersInConflicts)
                {
                    var hasPayed = false;
                    if (!hasPayed && (item.HasAcceptedArbitration == null || !item.HasAcceptedArbitration.Value))
                    {
                        Guid guid = Guid.NewGuid();
                        FastArbitreEmails.ArbitrationAsked(item.User.Email, conflict.Id,
                                                           Request.UrlReferrer.DnsSafeHost + Url.Action("AskArbitration", "Viewer", new { conflictId = conflict.Id }),
                                                           Request.UrlReferrer.DnsSafeHost + Url.Action("Index", "Email", new { id = guid.ToString() }), guid);
                        hasPayed = true;
                    }
                    else
                    {
                        Guid guid = Guid.NewGuid();
                        FastArbitreEmails.ArbitrationSentToCentre(item.User.Email, conflict.Id,
                                                                  Request.UrlReferrer.DnsSafeHost + Url.Action("AskArbitration", "Viewer", new { conflictId = conflict.Id }),
                                                                  Request.UrlReferrer.DnsSafeHost + Url.Action("Index", "Email", new { id = guid.ToString() }), guid);
                    }
                }
            }
            else
            {
                foreach (var item in conflict.UsersInConflicts.Where(c => c.HasAcceptedArbitration == null || !c.HasAcceptedArbitration.Value))
                {
                    Guid guid = Guid.NewGuid();
                    FastArbitreEmails.ArbitrationAsked(item.User.Email, conflict.Id,
                                                       Request.UrlReferrer.DnsSafeHost + Url.Action("AskArbitration", "Viewer", new { conflictId = conflict.Id }),
                                                       Request.UrlReferrer.DnsSafeHost + Url.Action("Index", "Email", new { id = guid.ToString() }), guid);
                }
            }
            return(RedirectToAction("Conflict", new { conflictId = conflictId }));
        }