internal void AddVolunteerContractToDB(Volcontract contract)
        {
            IMongoCollection <Volcontract> volcontractcollection = dBContext.Database.GetCollection <Volcontract>("Contracts");

            modifiedDocumentManager.AddIDtoString(contract._id);
            volcontractcollection.InsertOne(contract);
        }
        internal void UpdateVolunteerContract(Volcontract contractupdate, string id)
        {
            IMongoCollection <Volcontract> volcontractcollection = dBContext.Database.GetCollection <Volcontract>("Contracts");
            var filter = Builders <Volcontract> .Filter.Eq("_id", id);

            contractupdate._id = id;
            modifiedDocumentManager.AddIDtoString(id);
            volcontractcollection.FindOneAndReplace(filter, contractupdate);
        }
        internal Volcontract GetVolunteerContract(string id)
        {
            IMongoCollection <Volcontract> volcontractcollection = dBContext.Database.GetCollection <Volcontract>("Contracts");
            var filter = Builders <Volcontract> .Filter.Eq("_id", id);

            Volcontract returnVolContract = volcontractcollection.Find(filter).FirstOrDefault();

            return(returnVolContract);
        }
示例#4
0
 public ActionResult Create(Volcontract volcontract, string idofvol)
 {
     try
     {
         if (ModelState.IsValid)
         {
             Volunteer vol = volunteerManager.GetOneVolunteer(idofvol);
             volcontract._id              = Guid.NewGuid().ToString();
             volcontract.ExpirationDate   = volcontract.ExpirationDate.AddDays(1);
             volcontract.RegistrationDate = volcontract.RegistrationDate.AddDays(1);
             volcontract.Birthdate        = vol.Birthdate;
             volcontract.Fullname         = vol.Fullname;
             volcontract.CNP              = vol.CNP;
             volcontract.CIseria          = vol.CIseria;
             volcontract.CINr             = vol.CINr;
             volcontract.CIEliberat       = vol.CIEliberat;
             volcontract.Nrtel            = vol.ContactInformation.PhoneNumber;
             volcontract.Hourcount        = vol.HourCount;
             volcontract.CIeliberator     = vol.CIeliberator;
             string address = string.Empty;
             if (vol.Address.District != null && vol.Address.District != "-")
             {
                 address = vol.Address.District;
             }
             if (vol.Address.City != null && vol.Address.City != "-")
             {
                 address = address + "," + vol.Address.City;
             }
             if (vol.Address.Street != null && vol.Address.Street != "-")
             {
                 address = vol.Address.District;
             }
             if (vol.Address.Number != null && vol.Address.Number != "-")
             {
                 address = address + "," + vol.Address.City;
             }
             volcontract.Address = address;
             volcontract.OwnerID = idofvol;
             volContractManager.AddVolunteerContractToDB(volcontract);
             return(RedirectToAction("Index", new { idofvol }));
         }
     }
     catch
     {
         ModelState.AddModelError("", "Unable to save changes! ");
     }
     return(RedirectToAction("Create", new { idofvol }));
 }