Ejemplo n.º 1
0
    public void UpdateSpecialisation(int index)
    {
        if (!database.specialisations[index].specialisationHasLimit || (database.specialisations[index].specialisationHasLimit && database.specialisations[index].specialisationLimit > database.specialisations[index].currentCount))
        {
            specialisationID = index;
            database.specialisations [index].currentCount++;

            // Change the model
            for (int i = 0; i < database.specialisations.Count; i++)
            {
                transform.GetChild(i).gameObject.SetActive(false);
                if (transform.GetChild(i).gameObject.name == database.specialisations [index].model.name)
                {
                    transform.GetChild(i).gameObject.SetActive(true);
                }
            }
            GetComponent <Unit> ().SetAnimator();

            // Change the count on the specialisation
            if (_specialisationID != -1)
            {
                database.specialisations [_specialisationID].currentCount--;
            }

            _specialisationID = index;
            specialisation    = database.specialisations [index];
        }
    }
Ejemplo n.º 2
0
        public SpecialisationDto CreateOrUpdateSpecialisation(int id, int producttype, string name)
        {
            Specialisation specialisation = null;

            if (id > 0)
            {
                specialisation = Get <Specialisation>(s => s.Id == id);
            }
            else
            {
                specialisation = new Specialisation();
            }
            specialisation.Name = name;
            var product = Get <ProductType>(p => p.Id == producttype);

            if (product == null)
            {
                throw new Exception("producttype not found");
            }
            specialisation.ProductTypeId = producttype;
            Add(specialisation);
            SaveContext();
            var dbspec = Get <Specialisation>(s => s.Id == specialisation.Id, s => s.ProductType);

            if (dbspec == null)
            {
                throw new Exception("Ошибка добавления специализации");
            }
            return(new SpecialisationDto(dbspec, true));
        }
        public async Task <Specialisation> UpdateSpecialisation(Specialisation specialisation)
        {
            var tokenResponse = await _tokenService.GetToken("groupsapi.read");

            _httpClient
            .SetBearerToken(tokenResponse.AccessToken);

            _httpClient.BaseAddress = new Uri("https://localhost:5446/");

            var request = new HttpRequestMessage(HttpMethod.Put, $"Specialisations/{specialisation}");

            request.Content = JsonContent.Create <Specialisation>(specialisation);

            var response = await _httpClient.SendAsync(request);

            if (response.IsSuccessStatusCode)
            {
                var readTask = response.Content.ReadAsAsync <Specialisation>();
                readTask.Wait();

                return(readTask.Result);
            }
            else
            {
                throw new Exception("Unable to get content");
            }
        }
        // GET: Specialisations/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Specialisation specialisation = db.Specialisations.Find(id);

            if (specialisation == null)
            {
                return(HttpNotFound());
            }


            return(View(specialisation));

            /*/Object of selected attributes of students
             * var tutorObject = from t in db.Students
             *                select new {t.StudentID, t.FirstName, t.LastName, t.Gender, t.Ethnicity, t.CellphoneNo, t.Email, t.LevelOfStudy, t.Campus, t.College, t.Province, t.City, t.Suburb, t.StreetName, t.PostalCode, t.ProfilePicture };
             *
             * //Contains students id's
             * var studentIds = from st in tutorObject
             *               where st.StudentID.Equals(Session["ActiveStudentID"])
             *               select st;
             * //Object of selected attributes of Modules
             * var moduleObject = from m in db.Modules
             *                 select new {m.ModuleID, m.ModuleCode, m.Description };
             * //Contains modules id's
             * /*var moduleIds = from md in moduleObject
             *              where md.ModuleID.Equals("")
             *              select st;
             * return View(studentIds);*/
        }
        public async Task <Specialisation> CreateSpecialisation(Specialisation specialisation)
        {
            var tokenResponse = await _tokenService.GetToken("groupsapi.read");

            _httpClient
            .SetBearerToken(tokenResponse.AccessToken);

            _httpClient.BaseAddress = new Uri("https://localhost:5446/");

            var request = new HttpRequestMessage(HttpMethod.Post, $"Specialisations");

            request.Content = new StringContent(JsonConvert.SerializeObject(specialisation), System.Text.Encoding.UTF8, "application/json");

            var response = await _httpClient.SendAsync(request);

            if (response.IsSuccessStatusCode)
            {
                var readTask = response.Content.ReadAsAsync <Specialisation>();
                readTask.Wait();

                return(readTask.Result);
            }
            else
            {
                throw new Exception("Unable to get content");
            }
        }
Ejemplo n.º 6
0
        public List <Specialisation> GetSpecialisation()
        {
            string queryPaper = "SELECT * FROM specialisation where IsActive = 1";
            List <Specialisation> specialisationList = new List <Specialisation>();

            MySqlCommand cmd = new MySqlCommand();

            using (MySqlConnection con = new MySqlConnection(DBConnection.ConnectionString))
            {
                cmd.Connection = con;
                con.Open();
                cmd.CommandText = queryPaper;
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Specialisation objSpecialiation = new Specialisation();
                    objSpecialiation.specialisationId = Convert.ToInt32(reader["specialisationId"]);
                    objSpecialiation.specialisation   = reader["specialisation"].ToString();
                    objSpecialiation.IsActive         = Convert.ToInt32(reader["IsActive"]);
                    specialisationList.Add(objSpecialiation);
                }
            }

            return(specialisationList);
        }
Ejemplo n.º 7
0
 void Start()
 {
     tooltip                = GameObject.Find("UI").transform.Find("Tooltip").GetComponent <Tooltip>();
     survivorManager        = GameObject.Find("GameManager").GetComponent <SurvivorManager> ();
     specialisationDatabase = GameObject.Find("SpecialisationDatabase").GetComponent <SpecialisationDatabase> ();
     specialisation         = specialisationDatabase.specialisations [specialisationId];
 }
        public async Task <IActionResult> Edit(int id, [Bind("SpecID,SpecName")] Specialisation specialisation)
        {
            if (id != specialisation.SpecID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(specialisation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SpecialisationExists(specialisation.SpecID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(specialisation));
        }
Ejemplo n.º 9
0
    void Start()
    {
        doctorSpecialisation = GameObject.Find("SpecialisationDatabase").GetComponent <SpecialisationDatabase>().specialisations[3];
        waveManager          = GameObject.Find("GameManager").GetComponent <WaveManager> ();

        waveManager.waveEndEvent += OnWaveEnd;
    }
Ejemplo n.º 10
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,DepartmentId,Name")] Specialisation specialisation)
        {
            if (id != specialisation.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(specialisation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SpecialisationExists(specialisation.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Departments, "Id", "Name", specialisation.DepartmentId);
            return(View(specialisation));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Specialisation specialisation = db.Specialisations.Find(id);

            db.Specialisations.Remove(specialisation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public IActionResult PostSpecialisation([FromBody] Specialisation specialisation)
 {
     using (var scope = new TransactionScope())
     {
         _specialisationRepository.Add(specialisation);
         scope.Complete();
         return(CreatedAtAction(nameof(GetSpecialisation), new { id = specialisation.SpecialisationId }, specialisation));
     }
 }
Ejemplo n.º 13
0
        public async Task <IActionResult> Create(Specialisation specialisation)
        {
            if (ModelState.IsValid)
            {
                await apiClient.CreateSpecialisation(specialisation);

                return(RedirectToAction("Index"));
            }
            return(View(specialisation));
        }
        public async Task <IActionResult> Create([Bind("SpecID,SpecName")] Specialisation specialisation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(specialisation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(specialisation));
        }
Ejemplo n.º 15
0
        public void OnGet(int id)
        {
            //using (var db = new SpartaDB())
            //{
            var data = (from o in db.Specialisation
                        where o.SpecialisationID == id
                        select o).SingleOrDefault();

            SpecialisationSelected = data;
            //}
        }
 public ActionResult Edit([Bind(Include = "SpecialisationID,ModuleID,TutorID")] Specialisation specialisation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(specialisation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ModuleID = new SelectList(db.Modules, "ModuleID", "ModuleCode", specialisation.ModuleID);
     ViewBag.TutorID  = new SelectList(db.Tutors, "TutorID", "Experience", specialisation.TutorID);
     return(View(specialisation));
 }
Ejemplo n.º 17
0
        public async Task <IActionResult> Create([Bind("Id,DepartmentId,Name")] Specialisation specialisation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(specialisation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Departments, "Id", "Name", specialisation.DepartmentId);
            return(View(specialisation));
        }
Ejemplo n.º 18
0
    void Start()
    {
        IncreaseRations(startingFood);

        hungerManager        = GetComponent <HungerManager> ();
        reportManager        = GetComponent <ReportManager> ();
        farmerSpecialisation = GameObject.Find("SpecialisationDatabase").GetComponent <SpecialisationDatabase> ().specialisations[1];

        waveManager = GetComponent <WaveManager> ();
        waveManager.waveEndEvent += OnWaveEnd;

        UpdateUI();
    }
Ejemplo n.º 19
0
        public void Update(Specialisation specialisation)
        {
            var update = _dbContext.Specialisations
                         .Where(update => update.SpecialisationId.Equals(specialisation.SpecialisationId))
                         .SingleOrDefault();

            if (update != default(Specialisation))
            {
                update.Name = specialisation.Name;
            }

            Save();
        }
        // GET: Specialisations/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Specialisation specialisation = db.Specialisations.Find(id);

            if (specialisation == null)
            {
                return(HttpNotFound());
            }
            return(View(specialisation));
        }
        public IActionResult PutSpecialisation([FromBody] Specialisation specialisation)
        {
            if (specialisation != null)
            {
                using (var scope = new TransactionScope())
                {
                    _specialisationRepository.Update(specialisation);
                    scope.Complete();
                    return(new OkResult());
                }
            }

            return(new NoContentResult());
        }
Ejemplo n.º 22
0
        public NomenklaturaDto CreateOrUpdateNomenklatura(int id, string name, string code, int specialisationId, int lifestyle, decimal baseprice, int basecount, string description, string pictureurl, int externalId = 0)
        {
            Nomenklatura nomenklatura = null;

            if (id > 0)
            {
                nomenklatura = Get <Nomenklatura>(n => n.Id == id);
            }
            if (nomenklatura == null)
            {
                nomenklatura            = new Nomenklatura();
                nomenklatura.PictureUrl = UrlNotFound;
                nomenklatura.Code       = string.Empty;
                Add(nomenklatura);
            }
            nomenklatura.Name        = name;
            nomenklatura.Code        = code;
            nomenklatura.BasePrice   = baseprice;
            nomenklatura.Description = description;
            nomenklatura.PictureUrl  = pictureurl;
            if (externalId != 0)
            {
                nomenklatura.ExternalId = externalId;
            }
            nomenklatura.BaseCount = basecount;
            Specialisation specialisation = null;

            if (specialisationId > 0)
            {
                specialisation = Get <Specialisation>(p => p.Id == specialisationId);
            }
            else
            {
                specialisation = Get <Specialisation>(p => p.Id == nomenklatura.SpecialisationId);
            }
            if (specialisation == null)
            {
                throw new BillingException("specialisation not found");
            }
            nomenklatura.SpecialisationId = specialisation.Id;
            nomenklatura.Lifestyle        = lifestyle;
            nomenklatura.Lifestyle        = (int)BillingHelper.GetLifestyle(nomenklatura.Lifestyle);
            SaveContext();
            nomenklatura = GetAsNoTracking <Nomenklatura>(n => n.Id == nomenklatura.Id, n => n.Specialisation.ProductType);
            if (nomenklatura == null)
            {
                throw new Exception("Создать nomenklatura не получилось");
            }
            return(new NomenklaturaDto(nomenklatura, true));
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Specialisation = await _context.Specialisations.FirstOrDefaultAsync(m => m.SpecialisationID == id);

            if (Specialisation == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Ejemplo n.º 24
0
 public SpecialisationDto(Specialisation specialisation, bool main, decimal ratio = 0) : base(specialisation.ProductType, false)
 {
     if (specialisation == null)
     {
         return;
     }
     if (main)
     {
         Id   = specialisation.Id;
         Name = specialisation.Name;
     }
     this.SpecialisationName = specialisation.Name;
     this.SpecialisationId   = specialisation.Id;
     this.DiscountType       = specialisation.ProductType.DiscountType;
     this.Ratio = ratio;
 }
        // GET: Specialisations/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Specialisation specialisation = db.Specialisations.Find(id);

            if (specialisation == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ModuleID = new SelectList(db.Modules, "ModuleID", "ModuleCode", specialisation.ModuleID);
            ViewBag.TutorID  = new SelectList(db.Tutors, "TutorID", "Experience", specialisation.TutorID);
            return(View(specialisation));
        }
        public void ApproveTutor(int?id)
        {
            TutorApplication tutorApplication = db.TutorApplications.Find(id);

            if (tutorApplication != null)
            {
                tutorApplication.ApplicationStatus = "Approved";
                UserManager.AddToRole(tutorApplication.Student.Id, "Tutor");

                Tutor newTutor = new Tutor();
                newTutor.StudentID     = tutorApplication.Student.StudentID;
                newTutor.Experience    = "None";
                newTutor.Qualification = tutorApplication.Student.LevelOfStudy;
                newTutor.StreetName    = tutorApplication.Student.StreetName;
                newTutor.RatePerHour   = "100";
                newTutor.Status        = "Approved";
                newTutor.TotalRating   = 0;
                newTutor.NoOfSessions  = 0;
                db.Tutors.Add(newTutor);
                db.SaveChanges();
                Specialisation newSpec    = new Specialisation();
                var            newTutorId = from tutor in db.Tutors
                                            where tutor.StudentID == tutorApplication.StudentID
                                            select tutor.TutorID;
                int currentTutorId = 0;
                foreach (int i in newTutorId)
                {
                    currentTutorId = i;
                }
                ;
                newSpec.TutorID = currentTutorId;
                var newModule = from module in db.Modules
                                where module.ModuleCode == tutorApplication.ModuleCode
                                select module.ModuleID;
                int CurrentModuleID = 0;
                foreach (int i in newModule)
                {
                    CurrentModuleID = i;
                }
                newSpec.ModuleID = CurrentModuleID;
                db.Specialisations.Add(newSpec);
                db.SaveChanges();
            }
        }
Ejemplo n.º 27
0
            public override Action <IList <string> > GetCommand(string cmd)
            {
                return(cmd switch
                {
                    "respec" => new Action <IList <string> >(((args) =>
                    {
                        if (currentSpecialisation == Specialisation.Discipline)
                        {
                            currentSpecialisation = Specialisation.Shadow;
                        }
                        else if (currentSpecialisation == Specialisation.Shadow)
                        {
                            currentSpecialisation = Specialisation.Discipline;
                        }

                        Console.WriteLine($"Respecced Priest AI to {currentSpecialisation}");
                    })),
                    _ => null
                });
Ejemplo n.º 28
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (HttpContext.Session.GetString("Test") != "1")
            {
                return(RedirectToPage("/Login"));
            }
            if (id == null)
            {
                return(NotFound());
            }

            Specialisation = await _context.Specialisations.FirstOrDefaultAsync(m => m.SpecialisationID == id);

            if (Specialisation == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Ejemplo n.º 29
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (HttpContext.Session.GetString("Test") != "1")
            {
                return(RedirectToPage("/Login"));
            }
            if (id == null)
            {
                return(NotFound());
            }

            Specialisation = await _context.Specialisations.FindAsync(id);

            if (Specialisation != null)
            {
                _context.Specialisations.Remove(Specialisation);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 30
0
 public ActionResult Save(Specialisation model)
 {
     repo.Save(model);
     return(RedirectToAction("Index"));
 }