Example #1
0
        public JsonResult GetPersonsJson(string q, int?project_id, int page, int page_limit, int?value)
        {
            dbOperation = new DbPerson();
            var data = ((DbPerson)dbOperation).getPersons(q, project_id, page, page_limit);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Example #2
0
 public Form1()
 {
     InitializeComponent();
     dbUser   = new DbUser();
     dbParty  = new DbParty();
     dbPerson = new DbPerson();
 }
Example #3
0
 public static PersonModel ToPersonModel(this DbPerson person)
 {
     return(new PersonModel(person.Id, person.Name)
     {
         RoomId = person.RoomDisplayId,
         EnqueuedAt = person.EnqueuedAt,
     });
 }
Example #4
0
    private async Task <Person> addDBPersonAsync(DbPerson dbPerson)
    {
        await context.Persons.AddAsync(dbPerson);

        await context.SaveChangesAsync();

        return(mapper.Map <Person>(dbPerson));
    }
Example #5
0
        public JsonResult PersonInitJson(int?value)
        {
            dbOperation = new DbPerson();

            var data = ((DbPerson)dbOperation).PersonInit(value);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Example #6
0
        //
        // GET: /AdminHome/


        public ActionResult Persons()
        {
            DbPerson      PersonOperations;
            OperationBase dbOperation = new DbPerson();

            PersonOperations = (DbPerson)dbOperation;
            var model = PersonOperations.GetPersons();

            return(View(model));
        }
Example #7
0
        public ActionResult PersonResume(int Id)
        {
            DbPerson      PersonOperations;
            OperationBase dbOperation = new DbPerson();

            PersonOperations = (DbPerson)dbOperation;
            var model = PersonOperations.GetPersonDetailsById(Id);

            return(View(model));
        }
Example #8
0
    public async Task <Person> AddAsync(string name, string bio)
    {
        var dbPerson = new DbPerson()
        {
            Name = name,
            Bio  = bio
        };

        return(await addDBPersonAsync(dbPerson));
    }
Example #9
0
        public async Task <DbPerson> AddAsync(DbPerson person)
        {
            // Как это сделать по-человечески?
            //var lastId = _context.Persons.Select(dbPerson => dbPerson.Id).Last();
            //person.Id = lastId + 1;

            var result = await _context.Persons.AddAsync(person);

            await _context.SaveChangesAsync();

            return(result.Entity);
        }
Example #10
0
        public PersonModel CreatePerson(NewPersonModel newPerson)
        {
            var person = new DbPerson
            {
                Name = newPerson.Name
            };

            using var ctx = _contextFactory.CreateDbContext();
            ctx.People.Add(person);
            ctx.SaveChanges();

            return(person.ToPersonModel());
        }
        public HttpResponseMessage GetPerioderUtilgjenelig(int id)
        {
            var repository = new DbPerson();

            List <Utilgjengelig_ViewModel> liste = repository.getUtilgjengelig(id);

            var    Json       = new JavaScriptSerializer();
            string JsonString = Json.Serialize(liste);

            return(new HttpResponseMessage()
            {
                Content = new StringContent(JsonString, Encoding.UTF8, "application/json"),
                StatusCode = HttpStatusCode.OK
            });
        }
        public HttpResponseMessage PostUtilgjengelig([FromBody] Utilgjengelig_ViewModel input)
        {
            var  db = new DbPerson();
            bool ok = db.setUtilgjengelig(input);

            if (ok)
            {
                return(new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK
                });
            }
            return(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.BadRequest,
                Content = new StringContent("Søknaden ble ikke lagret!")
            });
        }
Example #13
0
        public ActionResult PersonResumeWithProjects(int Id)
        {
            DbPerson          PersonOperations;
            DbPersonsProjects ppOperations;
            OperationBase     dbOperation = new DbPerson();

            PersonOperations = (DbPerson)dbOperation;
            var           model        = PersonOperations.GetPersonDetailsById(Id);
            OperationBase dbOperation1 = new DbPersonsProjects();

            ppOperations = (DbPersonsProjects)dbOperation1;
            var ppModel = ppOperations.GetResumeByPersonID(Id);
            PersonResumeWithProjectsModel newModel = new PersonResumeWithProjectsModel();

            newModel.personModel    = model;
            newModel.personProjects = ppModel;
            return(View(newModel));
        }
Example #14
0
        public RemoveResult DeletePerson(long personId)
        {
            try
            {
                using var ctx = _contextFactory.CreateDbContext();
                var person = new DbPerson {
                    Id = personId
                };
                ctx.Attach(person);
                ctx.Remove(person);

                return(ctx.SaveChanges() > 0
                    ? RemoveResult.OK
                    : RemoveResult.AlreadyRemoved);
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Failed to remove person by ID '{personId}' from database.");
                return(RemoveResult.UnableToRemove);
            }
        }
Example #15
0
        public AddResult AddPersonToRoom(int roomId, long personId)
        {
            using var ctx = _contextFactory.CreateDbContext();

            var person = new DbPerson {
                Id = personId
            };

            ctx.Attach(person);
            person.RoomDisplayId = roomId;

            try
            {
                return(ctx.SaveChanges() > 0
                    ? AddResult.OK
                    : AddResult.AlreadyAdded);
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Failed to assign room by ID '{roomId}' to person by ID '{personId}'.");
                return(AddResult.UnableToAdd);
            }
        }
Example #16
0
        public RemoveResult RemovePersonFromRoom(int roomId, long personId)
        {
            using var ctx = _contextFactory.CreateDbContext();

            var person = new DbPerson {
                Id = personId
            };

            ctx.Attach(person);
            person.RoomDisplayId = null;

            try
            {
                return(ctx.SaveChanges() > 0
                    ? RemoveResult.OK
                    : RemoveResult.AlreadyRemoved);
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Failed to unassign room by ID '{roomId}' from person by ID '{personId}'.");
                return(RemoveResult.UnableToRemove);
            }
        }
Example #17
0
        /// <summary>
        /// Model instance
        /// </summary>
        public Core.Model.Roles.Provider ToModelInstance(DbProvider providerInstance, DbPerson personInstance, DbEntityVersion entityVersionInstance, DbEntity entityInstance, DataContext context)
        {
            var retVal = m_entityPersister.ToModelInstance <Core.Model.Roles.Provider>(entityVersionInstance, entityInstance, context);

            if (retVal == null)
            {
                return(null);
            }

            retVal.DateOfBirth = personInstance?.DateOfBirth;

            // Reverse lookup
            if (!String.IsNullOrEmpty(personInstance?.DateOfBirthPrecision))
            {
                retVal.DateOfBirthPrecision = PersonPersistenceService.PrecisionMap.Where(o => o.Value == personInstance.DateOfBirthPrecision).Select(o => o.Key).First();
            }

            retVal.LanguageCommunication = context.Query <DbPersonLanguageCommunication>(v => v.SourceKey == entityInstance.Key && v.EffectiveVersionSequenceId <= entityVersionInstance.VersionSequenceId && (v.ObsoleteVersionSequenceId == null || v.ObsoleteVersionSequenceId >= entityVersionInstance.VersionSequenceId))
                                           .ToArray()
                                           .Select(o => new Core.Model.Entities.PersonLanguageCommunication(o.LanguageCode, o.IsPreferred)
            {
                Key = o.Key
            })
                                           .ToList();
            retVal.ProviderSpecialtyKey = providerInstance?.Specialty;

            return(retVal);
        }
Example #18
0
 public PersonsController()
 {
     dbOperation      = new DbPerson();
     PersonOperations = (DbPerson)dbOperation;
 }
Example #19
0
 public Person(DbPerson databaseEntity)
     : base(false)
 {
     Mapper.Map(databaseEntity, this);
 }