public InstituteViewModel(IUserInterop userInterop, IControllerInterop controllerInterop, Dispatcher dispatcher, InstituteDTO institute)
            : base(userInterop, controllerInterop, dispatcher)
        {
            this.originalEntity = institute;

            this.Model = new InstituteModel(institute);
            this.Model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ModelPropertyChanged);
        }
        public FacultyModel(FacultyDTO faculty)
            : base(faculty)
        {
            institute = faculty.Institute;
            specializations = faculty.Specializations.ToModelList<SpecializationModel, SpecializationDTO>();

            specializations.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(specializations_CollectionChanged);
            foreach(SpecializationModel model in specializations)
                model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(model_PropertyChanged);
        }
Exemple #3
0
        public async Task <IActionResult> Get([FromRoute] InstituteQuery i)
        {
            try
            {
                InstituteDTO institute = await _dispatcher.QueryAsync(i);

                return(Ok(institute));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #4
0
        public async Task <IActionResult> UpdateInstituteProfile([FromBody] InstituteDTO institute)
        {
            var data = mapper.Map <InstituteDTO, Institute>(institute);

            data.UserId = UserIdRequested();
            var dataInserted = await unitOfWork.GetRepository <Institute>().InsertAsync(data);

            foreach (var item in institute.Reliance)
            {
                var relianceItem = new Reliance()
                {
                    InstituteId      = dataInserted.Id,
                    Logo             = item.Logo,
                    RelianceStatusId = item.Status,
                    Name             = item.Name,
                };
                await unitOfWork.GetRepository <Reliance>().InsertAsync(relianceItem);
            }

            return(ApiResponder.RespondSuccessTo(HttpStatusCode.Ok, dataInserted));
        }
        public HttpResponseMessage Update(HttpRequestMessage request, InstituteDTO item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            var dbObject = Mapper.Map <Institute>(item);

            if (_facultyRepository.GetById(dbObject.FacultyId) == null)
            {
                return(request.CreateErrorResponse(
                           HttpStatusCode.PreconditionFailed,
                           string.Format("Not found faculty with id: {0}", dbObject.FacultyId)));
            }

            _instituteRepository.Update(dbObject);
            _db.SaveChanges();

            var mapped = Mapper.Map <InstituteDTO>(dbObject);

            return(request.CreateResponse(HttpStatusCode.NoContent, mapped));
        }
        public async Task <List <InstituteDTO> > GetAllInstitutes()
        {
            var dt = new List <InstituteDTO>();
            await _connection.OpenAsync();

            try
            {
                using (MySqlCommand cmd = new MySqlCommand("Get_Institutes", _connection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    var dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        var row = new InstituteDTO();
                        row.Id          = Convert.ToInt32(dr["InstituteId"]);
                        row.Name        = dr["InstituteName"].ToString();
                        row.BranchName  = dr["InstituteBranchName"].ToString();
                        row.Description = dr["InstituteDescription"].ToString();

                        row.InstitutionType = new EntityDetail();
                        if (int.TryParse(dr["InstituteTypeId"].ToString(), out int InstituteTypeId))
                        {
                            row.InstitutionType.Id = InstituteTypeId;
                        }
                        row.InstitutionType.Name = dr["InstituteTypeName"].ToString();

                        row.EducationalBoard = new EntityDetail();
                        if (int.TryParse(dr["EducationalBoardId"].ToString(), out int EducationalBoardId))
                        {
                            row.EducationalBoard.Id = EducationalBoardId;
                        }
                        row.EducationalBoard.Name = dr["EducationalBoardName"].ToString();

                        row.ContactInfo = new DTO.Contact();
                        if (int.TryParse(dr["ContactId"].ToString(), out int ContactId))
                        {
                            row.ContactInfo.ContactId = ContactId;
                        }
                        row.ContactInfo.LandLineNumber    = dr["LandlineNumber"].ToString();
                        row.ContactInfo.AltLandLineNumber = dr["AlternateLandLineNumber"].ToString();
                        row.ContactInfo.MobileNumber      = dr["MobileNumber"].ToString();
                        row.ContactInfo.AltMobileNumber   = dr["AlternateMobileNumber"].ToString();
                        row.ContactInfo.EmailId           = dr["EmailId"].ToString();
                        row.ContactInfo.AltEmailId        = dr["AlternateEmailId"].ToString();

                        row.BillingAddress = new DTO.Address();
                        if (int.TryParse(dr["BillingAddressId"].ToString(), out int BillingAddressId))
                        {
                            row.BillingAddress.AddressId = BillingAddressId;
                        }
                        row.BillingAddress.AddressLine1 = dr["BillingAddressLine1"].ToString();
                        row.BillingAddress.AddressLine2 = dr["BillingAddressLine2"].ToString();
                        row.BillingAddress.AddressLine3 = dr["BillingAddressLine3"].ToString();
                        row.BillingAddress.City         = dr["BillingAddressCity"].ToString();
                        row.BillingAddress.Zipcode      = dr["BillingAddressZip"].ToString();
                        row.BillingAddress.State        = new EntityDetail();
                        if (int.TryParse(dr["BillingStateId"].ToString(), out int BillingStateId))
                        {
                            row.BillingAddress.State.Id = BillingStateId;
                        }
                        row.BillingAddress.State.Name = dr["BillingState"].ToString();
                        row.BillingAddress.Country    = new EntityDetail();
                        if (int.TryParse(dr["BillingCountryId"].ToString(), out int BillingCountryId))
                        {
                            row.BillingAddress.Country.Id = BillingCountryId;
                        }
                        row.BillingAddress.Country.Name = dr["BillingCountry"].ToString();

                        row.MailingAddress = new DTO.Address();
                        if (int.TryParse(dr["MailingAddressId"].ToString(), out int MailingAddressId))
                        {
                            row.MailingAddress.AddressId = MailingAddressId;
                        }
                        row.MailingAddress.AddressLine1 = dr["MailingAddressLine1"].ToString();
                        row.MailingAddress.AddressLine2 = dr["MailingAddressLine2"].ToString();
                        row.MailingAddress.AddressLine3 = dr["MailingAddressLine3"].ToString();
                        row.MailingAddress.City         = dr["MailingAddressCity"].ToString();
                        row.MailingAddress.Zipcode      = dr["MailingAddressZip"].ToString();
                        row.MailingAddress.State        = new EntityDetail();
                        if (int.TryParse(dr["MailingStateId"].ToString(), out int MailingStateId))
                        {
                            row.MailingAddress.State.Id = MailingStateId;
                        }
                        row.MailingAddress.State.Name = dr["MailingState"].ToString();

                        row.MailingAddress.Country = new EntityDetail();
                        if (int.TryParse(dr["MailingCountryId"].ToString(), out int MailingCountryId))
                        {
                            row.MailingAddress.Country.Id = MailingCountryId;
                        }
                        row.MailingAddress.Country.Name = dr["MaillingCountry"].ToString();

                        dt.Add(row);
                    }
                }

                return(dt);
            }
            catch { throw; }
            finally { await _connection.CloseAsync(); }
        }