Exemplo n.º 1
0
        private void ddlTitles_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlTitles.SelectedItem == null)
            {
                return;
            }
            TitleModel selectedItem = (TitleModel)ddlTitles.SelectedItem;
            Worker     worker       = WorkerProvider.Instance.GetItems("TitleId", selectedItem.Id).FirstOrDefault();

            if (worker != null)
            {
                if (!worker.IsActive)
                {
                    DialogResult result = MessageBox.Show("Tanımlamaya çalıştığınız ünvan pasif'e ayırmışsınız. Aktifleştirmek istermisiniz?", "Pasif", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    if (result.Equals(DialogResult.OK))
                    {
                        worker.IsActive = true;
                        WorkerProvider.Instance.Save(worker);
                        this.LoadGrid();
                    }
                    ddlTitles.SelectedItem = null;
                }
                else
                {
                    MessageBox.Show("Tanımlamaya çalıştığınız ünvan zaten tanımlı. Güncelleme yapabilirsiniz.");
                    ddlTitles.SelectedItem = null;
                }
            }
        }
Exemplo n.º 2
0
        public IActionResult GetOneTitle(int empNo, string title, DateTime fromDate)
        {
            try
            {
                Title t = _titleService.GetOneTitle(empNo, title, fromDate);

                if (t == null)
                {
                    return(NoContent());
                }

                TitleModel resultTitle = new TitleModel
                {
                    Employee       = t.Employee,
                    EmployeeNumber = t.EmployeeNumber,
                    EmployeeTitle  = t.Title,
                    FromDate       = t.FromDate,
                    ToDate         = t.ToDate
                };

                return(Ok(resultTitle));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, APIResponse.DefaultErrorMessage(ex.Message, 500)));
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Add(TitleModel titleModel, string type)
        {
            if (ModelState.IsValid)
            {
                if ((await _titleManager.GetAll()).Any(entity => entity.Name == titleModel.Name))
                {
                    return(Json(new
                    {
                        success = false,
                        messages = new[] { ValidationMessages.TitleNameAlreadyExist }
                    }));
                }

                await using var coverStream = titleModel.Cover?.OpenReadStream();

                if (await _titleArchiver.AddTitle(Mapper.MapToEntity(titleModel, type), titleModel.Tags?.Split(","), coverStream))
                {
                    TempData["SuccessMessage"] = new[] { OtherMessages.TitleAddedSuccessfully };

                    return(Json(new
                    {
                        success = true,
                        destination = Url.Action("Index")
                    }));
                }

                ModelState.AddModelError("SomethingWrong", OtherMessages.SomethingWrong);
            }

            return(Json(new
            {
                success = false,
                messages = ModelState.SelectMany(state => state.Value.Errors).Select(error => error.ErrorMessage)
            }));
        }
Exemplo n.º 4
0
        public title ConvertModelToEntity(TitleModel model, int userId = -1)
        {
            title entity = new title();

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

            entity.name      = model.Name;
            entity.isCurrent = model.IsCurrent;

            if (model.Id > 0)
            {
                entity.id = model.Id;
            }

            if (userId > 0)
            {
                if (entity.id > 0)
                {
                    entity.editedById   = userId;
                    entity.editedByDate = System.DateTime.Now;
                }
                else //entity.id <= 0
                {
                    entity.createdById   = userId;
                    entity.createdByDate = System.DateTime.Now;
                }
            }

            return(entity);
        }
Exemplo n.º 5
0
        public TitleController(TitleView view, TitleModel model, SceneTransitionService sceneTransitionService, AudioService audioService)
            : base(view)
        {
            _view = view;
            _view.Initialize();

            _model                  = model;
            _audioService           = audioService;
            _sceneTransitionService = sceneTransitionService;

            _view.OnStartClicked
            .Subscribe(_ => OnStartClicked())
            .AddTo(Disposer);

            _view.OnSettingsClicked
            .Subscribe(_ => _model.OpenSettings.Execute())
            .AddTo(Disposer);

            _view.OnCreditsClicked
            .Subscribe(_ => _model.OpenCredits.Execute())
            .AddTo(Disposer);

            _view.OnTutorialClicked
            .Subscribe(_ => _model.OpenTutorial.Execute())
            .AddTo(Disposer);
        }
Exemplo n.º 6
0
        public IHttpActionResult Post(TitleModel title)
        {
            try
            {
                var oldTitle = _ctx.Titles.Find(title.ID);
                if (oldTitle != null)
                {
                    return(Put(title.ID, title));
                }
                if (!ModelState.IsValid || title == null)
                {
                    return(BadRequest(ModelState));
                }
                var newTitle = _ctx.Titles.Add(title);
                _ctx.SaveChanges();

                if (newTitle == null)
                {
                    return(BadRequest(ModelState));
                }

                return(Ok());
            }

            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        } // New Title Method
Exemplo n.º 7
0
        public TitleModel GetById(int id)
        {
            title      entity = this._repository.GetById(id);
            TitleModel model  = this.ConvertEntityToModel(entity);

            return(model);
        }
Exemplo n.º 8
0
        public IHttpActionResult Put(int id, TitleModel title)
        {
            try
            {
                if (title == null)
                {
                    return(BadRequest("Could not read department from body"));
                }

                var originalTitle = _ctx.Titles.Find(id);

                if (originalTitle == null || originalTitle.ID != id)
                {
                    return(BadRequest("department is not found"));
                }
                else
                {
                    title.ID = id;
                }
                _ctx.Entry(originalTitle).CurrentValues.SetValues(title);
                _ctx.SaveChanges();
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        } // Update Title Method
Exemplo n.º 9
0
        public IActionResult PutTitle(
            int empNo,
            string title,
            DateTime fromDate,
            [FromBody] TitleModel titleModel
            )
        {
            try
            {
                Title titleToUpdate = new Title
                {
                    EmployeeNumber = empNo,
                    Title          = title,
                    FromDate       = fromDate,
                    ToDate         = titleModel.ToDate
                };

                _titleService.UpdateTitle(titleToUpdate);

                TitleModel updatedTitle = new TitleModel
                {
                    EmployeeNumber = titleToUpdate.EmployeeNumber,
                    EmployeeTitle  = titleToUpdate.Title,
                    FromDate       = titleToUpdate.FromDate,
                    ToDate         = titleToUpdate.ToDate
                };

                return(Ok(updatedTitle));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, APIResponse.DefaultErrorMessage(ex.Message, 500)));
            }
        }
Exemplo n.º 10
0
        public ActionResult Index()
        {
            var model = new TitleModel();

            model.Title = "New Awesome Title";

            return(View(model));
        }
Exemplo n.º 11
0
 public static Title ToEntity(this TitleModel modelTitle)
 {
     return(new Title
     {
         Id = modelTitle.Id,
         Name = modelTitle.Name
     });
 }
Exemplo n.º 12
0
        public async Task <SearchResultModel> SearchTitle(string titleText)
        {
            Uri uri = new Uri("https://eksisozluk.com/");

            uri = uri.AddParameter("q", titleText);

            var request = new HttpRequestMessage()
            {
                RequestUri = uri,
                Method     = HttpMethod.Get,
            };

            // TODO : @deniz geçici olarak yapıldı. Nested tipleri handle edilen yapı oluşturulduğunda değiştirilecek
            using (HttpClient httpClient = new HttpClient())
            {
                using (HttpResponseMessage httpResponseMessage = await httpClient.SendAsync(request))
                {
                    string htmlContent = await httpResponseMessage.Content.ReadAsStringAsync();

                    SearchResultModel searchResultModel = new SearchResultModel();

                    if (httpResponseMessage.StatusCode == HttpStatusCode.OK)
                    {
                        string titleNameIdText = httpResponseMessage.RequestMessage.RequestUri.AbsolutePath;

                        TitleModel titleModel = _bindingComponent
                                                .Binder()
                                                .BindModelHtmlContent <TitleModel>(htmlContent, model => model.TitleNameIdText = titleNameIdText)
                                                .FirstOrDefault();

                        titleModel = titleModel ??
                                     new TitleModel()
                        {
                            CurrentPage     = "1",
                            PageCount       = "1",
                            TitleNameIdText = titleNameIdText
                        };

                        titleModel.EntryDetailModels = _bindingComponent
                                                       .Binder()
                                                       .BindModelHtmlContent <EntryDetailModel>(htmlContent, c => c.Content = c.Content.FixLinks())
                                                       .ToList();

                        searchResultModel.TitleModel = titleModel;

                        searchResultModel.Result = true;

                        return(searchResultModel);
                    }

                    searchResultModel.SuggestedTitleModels = _bindingComponent
                                                             .Binder()
                                                             .BindModelHtmlContent <SuggestedTitleModel>(htmlContent).ToList();

                    return(searchResultModel);
                }
            }
        }
Exemplo n.º 13
0
        [HttpPost]/*, ValidateAntiForgeryToken]*/
        public ActionResult TitleSilentSave(TitleModel model)
        {
            if (ModelState.IsValid && model.UserHasAccess)
            {
                model.Save();
            }

            return(null);
        }
Exemplo n.º 14
0
        [HttpPost]/*, ValidateAntiForgeryToken]*/
        public ActionResult TitleSave(TitleModel model)
        {
            if (ModelState.IsValid && SortMainObject.CheckUserHasWriteAccess(model.SortMainId))
            {
                model.Save();
            }

            return(null);
        }
Exemplo n.º 15
0
        [HttpPost]/*, ValidateAntiForgeryToken]*/
        public ActionResult TitleSave(TitleModel model)
        {
            if (ModelState.IsValid && model.UserHasAccess)
            {
                model.Save();
            }

            return(RedirectToAction("Index", new { id = model.MainId }));
        }
Exemplo n.º 16
0
        public IActionResult GetTitlesByEmployeeNumber(
            [FromQuery] bool currentTitles,
            [FromQuery] int page,
            [FromQuery] int pageSize,
            [FromQuery(Name = "sort")] string sort,
            [FromQuery(Name = "filter")] string filter,
            int empNo
            )
        {
            try
            {
                page     = (page <= 0) ? Constants.PageDefaultOffset : page;
                pageSize = (pageSize <= 0) ? Constants.PageDefaultLimit : pageSize;
                sort     = sort ?? Constants.PageDefaultSort;
                filter   = filter ?? Constants.TitleModelDefaultFilter;

                List <TitleModel> titleModels = new List <TitleModel>();

                _titleService
                .GetTitlesByFiltersAndEmployeeNumber(empNo, page, pageSize, sort, filter)
                .ToList().ForEach(foundTitle =>
                {
                    TitleModel t = new TitleModel
                    {
                        Employee       = foundTitle.Employee,
                        EmployeeNumber = foundTitle.EmployeeNumber,
                        EmployeeTitle  = foundTitle.Title,
                        FromDate       = foundTitle.FromDate,
                        ToDate         = foundTitle.ToDate
                    };
                    if (currentTitles)
                    {
                        if (foundTitle.ToDate.Equals(Constants.DatabaseDefaultDate))
                        {
                            titleModels.Add(t);
                        }
                    }
                    else
                    {
                        titleModels.Add(t);
                    }
                });

                if (titleModels.Count <= 0)
                {
                    return(NoContent());
                }

                return(Ok(titleModels));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, APIResponse.DefaultErrorMessage(ex.Message, 500)));
            }
        }
Exemplo n.º 17
0
        public CreditsController(CreditsView view, TitleModel model)
            : base(view)
        {
            _view = view;
            _view.Initialize();

            _model = model;
            _model.OpenCredits
            .Subscribe(_ => Open())
            .AddTo(Disposer);
        }
Exemplo n.º 18
0
 public IHttpActionResult Post(TitleModel model, int userId)
 {
     try
     {
         int result = _service.Insert(model, userId);
         return(Ok(result));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message.ToString()));
     }
 }
Exemplo n.º 19
0
        public void LoadWorkerTitles()
        {
            ddlTitles.Properties.Items.Clear();
            List <TitleModel> models = UITitleManager.Instance.GetTitles();

            ddlTitles.Properties.Items.AddRange(models);
            if (this.SelectedTitleId != 0)
            {
                TitleModel selectedTite  = models.Where(p => p.Id == this.SelectedTitleId).FirstOrDefault();
                int        selectedIndex = models.IndexOf(selectedTite);
                ddlTitles.SelectedIndex = selectedIndex;
            }
        }
Exemplo n.º 20
0
        private TitleModel GetDemoItem(bool isNew)
        {
            TitleModel item = new TitleModel()
            {
                Name = "Demo name", IsCurrent = true
            };

            if (!isNew)
            {
                item.Id = 1;
            }

            return(item);
        }
        public async Task <List <string> > FetchImages(TitleModel titleModel)
        {
            List <string> result = await FetchImages(titleModel.Title, titleModel.EmuMoviesSystem, EmuMoviesMediaTypes.Cart);

            if (result.Count == 0)
            {
                result.AddRange(await FetchImages(titleModel.Title, titleModel.EmuMoviesSystem, EmuMoviesMediaTypes.CD));
            }
            if (result.Count == 0)
            {
                result.AddRange(await FetchImages(titleModel.Title, titleModel.EmuMoviesSystem, EmuMoviesMediaTypes.Disc));
            }

            return(result);
        }
Exemplo n.º 22
0
        public TitleModel CreateTitle(TitleModel newTitleRecord)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString("WorkDeskDB")))
            {
                var p = new DynamicParameters();
                p.Add("@Name");
                p.Add("@ID", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);

                newTitleRecord.ID = p.Get <int>("@ID");

                connection.Execute("dbo.spTitle_Insert");

                return(newTitleRecord);
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// To the view model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public static TitleViewModel ToViewModel(this TitleModel model)
        {
            if (model == null)
            {
                return(null);
            }

            var entity = new TitleViewModel
            {
                TitleID = model.TitleID,
                Title   = model.Title
            };

            return(entity);
        }
Exemplo n.º 24
0
        public void GetById_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            var repository = new TitleRepository(context);
            var service    = new TitleService(repository);
            int id         = 1;

            // Act
            TitleModel result = service.GetById(id);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(id, result.Id);
        }
Exemplo n.º 25
0
        public void ConvertModelToEntity_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            var        service           = new TitleService();
            TitleModel model             = GetTestModel();

            // Act
            title entity = service.ConvertModelToEntity(model);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(entity.name, model.Name);
            Assert.AreEqual(entity.isCurrent, model.IsCurrent);
        }
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            var titleModel   = new TitleModel("Delegati first part");
            var consoleModel = new ConsoleModel();

            consoleModel.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(titleModel.ToString());
            consoleModel.Title = "Delegate first part";

            Transformer t      = Squere;
            int         result = t(3);

            Console.WriteLine(result);
            Console.ReadKey(true);
        }
Exemplo n.º 27
0
        /// <summary>
        /// To the model.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static TitleModel ToModel(this TitleViewModel entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new TitleModel
            {
                TitleID = entity.TitleID,
                Title   = entity.Title
            };

            return(model);
        }
Exemplo n.º 28
0
        public TitleModel getTitle(string tableName, string shiYanHao)
        {
            TitleModel title = new TitleModel();

            try
            {
                SqlConnection();
            }
            catch (Exception e)
            {
                throw e;
            }

            sqlStr = "select * from " + tableName + " where 实验号 = '" + shiYanHao + "'";

            try
            {
                dataControl = new DataControl();
                reader      = dataControl.controlSql(sqlCon, sqlStr);
            }
            catch (Exception e)
            {
                throw e;
            }

            reader.Read();

            title.Title             = Convert.ToString(reader["标题"]);
            title.TitleSpeed        = Convert.ToString(reader["标题速率"]);
            title.XLabel            = Convert.ToString(reader["x轴"]);
            title.YLabel            = Convert.ToString(reader["y轴"]);
            title.ShiYanHao         = Convert.ToString(reader["实验号"]);
            title.YLabelSpeed       = Convert.ToString(reader["y轴速率"]);
            title.chartMiaoShu      = Convert.ToString(reader["描述"]);
            title.chartSpeedMiaoShu = Convert.ToString(reader["速率图描述"]);


            try
            {
                SqlClose();
            }
            catch (Exception e)
            {
                throw e;
            }

            return(title);
        }
Exemplo n.º 29
0
        public TitleModel ConvertEntityToModel(title entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new TitleModel()
            {
                Id        = entity.id,
                Name      = entity.name.Trim(),
                IsCurrent = entity.isCurrent,
            };

            return(model);
        }
Exemplo n.º 30
0
        public async Task <IActionResult> Title(TitleModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Error(ModelState.Values.SelectMany(v => v.Errors).FirstOrDefault().ErrorMessage));
            }

            var Need = await Context.Need.Include(need => need.User).FirstOrDefaultAsync(x =>
                                                                                         x.Id == model.Id &&
                                                                                         !x.IsRemoved &&
                                                                                         x.UserId == Guid.Parse(User.Identity.GetUserId()));

            if (Need != null)
            {
                if (Need.Stage == 1)
                {
                    if (model.Title != Need.Title)
                    {
                        Need.Title         = model.Title.ClearExtraBlanks().CapitalizeFirstCharOfWords().RemoveLessGreaterSigns();
                        Need.FriendlyTitle = Need.Title.FriendlyUrl();
                        try
                        {
                            await Context.SaveChangesAsync();

                            return(Succes("Düzenlendi", new { Need.Link }, 201));
                        }
                        catch (Exception e)
                        {
                            string innerMessage = (e.InnerException != null) ? e.InnerException.Message : "";

                            if (innerMessage.Contains("Unique_Key_Title") || innerMessage.Contains("Unique_Key_FriendlyTitle"))
                            {
                                return(Error("Bu başlığı kullanamazsınız"));
                            }

                            return(Error("Başaramadık, ne olduğunu bilmiyoruz"));
                        }
                    }

                    return(Error("Hiç bir değişiklik yapılmadı"));
                }

                return(Error("Bu kampanyada değişiklik yapamazsın", "Stage must be 1"));
            }

            return(Error("Kampanya yok", null, null, 404));
        }